TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Navneet Rana
NA
9
4.9k
Register COM interop
Feb 25 2014 12:48 PM
Hello to All,
This is my very first time building an application which requires registering COM interop. The output of this application should be a library so as to load it into a different XYZ application that has COM scripting ability.The problem I am facing is the application I built works fine on my machine that has Visual Studio 2012(checking Register COM interop) But when I try it on a different machine, it wont properly in the XYZ application.After a lot of research and trying installShield installer , I have concluded that maybe I am missing something in my code.I was under the impression, that just declaring COMvisible to true and GUID attribute is enough.But I am surely missing something about the interface.I will really appreciate is someone can help me with a step by step tutorial for the same.
Below is what I am doing currently.
1) create a class library project and add the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Ivi.Visa.Interop;
namespace UsbLibraryCls
{
[Guid("0FB610DE-C81E-491E-BCC5-D897CDFA7CFD")]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class ComUsb
{
ResourceManager rMgr = new ResourceManager();
FormattedIO488 src = new FormattedIO488();
object resources = null;
public string OutputResources()
{
resources = rMgr.FindRsrc("USB[0-9]*::?*");
string[] resource_list = (string[])resources;
string allResources = String.Join(";", resource_list);
return allResources;
}
}
Here I add the VISA COM 3.0 library as a reference.
2) Create a console application:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using UsbLibraryCls;
namespace UsbLibConsole
{
class Program
{
static void Main(string[] args)
{
ComUsb Usb = new ComUsb();
Usb.OutputResources();
}
}
}
3) Both the projects are have x86 platform. And I check mark for "Register COM interop"
4) The library loads into the registery and I load this into the XYZ library by calling its ProgID.
And it works fine.
But When I try this on a any other target machine without VS with the same configurations as my laptop that has VS, the library loads into the registery but when i load it into the XYZ application it does not work.
I load it on the target machine by using RegAsm "fullpath\abc.dll" /tlb: abc.tlb /codebase.
I can say I have almost tried all the solutions I could find online. But I am missing some important detail.
All I want is when I call the OutputResources() function from the XYZ application. It should return a string with all the USB devices connected to the machine.
The code is barely 10 lines but I have spent more than a week trying this.
I am waiting on delivery of Install Sheild so have not tried that yet. But I created the .msi package
using advanced installer and installed it on target machine and still wont work.
I really would appreciate if anyone could point out where I am going wrong.
Thanks!
Reply
Answers (
5
)
Display graphic objects from spatialquery result on arcmap
Getting back Decimal address value of a USB device?