Com DLL file reference access ...
-
I have a com object dll file called MyCom.dll with some classes, interfaces, methods and events. I can add it as a reference to my project in visual studio IDE and create an instance from one interface that i need: MyDllLib.InterfaceName myobject = new MyDllLib.InterfaceName(); I can also access all the events and methods for this interface via myobject. So by some reason i dont want to add this com dll file to my project references and dont ask why! My question is how can instantiate an interface from a com dll file and access it's methods and events. If i dont add it as a reference in .Net IDE so i can't reference it. Could someone recommend the best solution for this. Thank You,:confused:
-
I have a com object dll file called MyCom.dll with some classes, interfaces, methods and events. I can add it as a reference to my project in visual studio IDE and create an instance from one interface that i need: MyDllLib.InterfaceName myobject = new MyDllLib.InterfaceName(); I can also access all the events and methods for this interface via myobject. So by some reason i dont want to add this com dll file to my project references and dont ask why! My question is how can instantiate an interface from a com dll file and access it's methods and events. If i dont add it as a reference in .Net IDE so i can't reference it. Could someone recommend the best solution for this. Thank You,:confused:
Shahin77 wrote:
i dont want to add this com dll file to my project references and dont ask why! My question is how can instantiate an interface from a com dll file and access it's methods and events.
Shahin77 wrote:
Could someone recommend the best solution for this.
There is no "best solution". Doing this just makes your life so much more difficult, it's not worth it. You've just about trippled the amount of time it'll take to write your code to consume this library, being that you lose all type safety and Intellisense, not to mention that you'll have to write the code to load this library and initialize it. You'll also need to write the code to lookup and instantiate objects, manually wire up events, ..., ..., yada, yada, yada... Why would you want to ignore all the benefits of early binding and having the compiler do all the dirty work for you??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Shahin77 wrote:
i dont want to add this com dll file to my project references and dont ask why! My question is how can instantiate an interface from a com dll file and access it's methods and events.
Shahin77 wrote:
Could someone recommend the best solution for this.
There is no "best solution". Doing this just makes your life so much more difficult, it's not worth it. You've just about trippled the amount of time it'll take to write your code to consume this library, being that you lose all type safety and Intellisense, not to mention that you'll have to write the code to load this library and initialize it. You'll also need to write the code to lookup and instantiate objects, manually wire up events, ..., ..., yada, yada, yada... Why would you want to ignore all the benefits of early binding and having the compiler do all the dirty work for you??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
The reason is im working on a project which is shared between 20 developers and i dont want to add any reference to the project, I dont want any dependency to this dll file when i compile. So any idea? Thank You
There isn't a way around this. The dependancy is GOING to be there no matter if you use a reference or not. With the reference, you just made using this library about 100x harder to use because now your developers have to write their own code to load the library, init it, lookup and instantiate objects, wire up events, ..., ..., ... It's simply not worth it. There is no "easy" way around this. If you've chosen to export your library as a COM-based .DLL, you've also locked yourself into DllHell and the dependancies that come with COM. You simply have no way around this. Now, if the library is exported as a normal .NET library, the dependancies go away and you can even setup the app's app.config file to redirect dependancies to new version of the library assembly.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
There isn't a way around this. The dependancy is GOING to be there no matter if you use a reference or not. With the reference, you just made using this library about 100x harder to use because now your developers have to write their own code to load the library, init it, lookup and instantiate objects, wire up events, ..., ..., ... It's simply not worth it. There is no "easy" way around this. If you've chosen to export your library as a COM-based .DLL, you've also locked yourself into DllHell and the dependancies that come with COM. You simply have no way around this. Now, if the library is exported as a normal .NET library, the dependancies go away and you can even setup the app's app.config file to redirect dependancies to new version of the library assembly.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007We didnt create this com dll file, we just have to use it and there are just one method call & one event handeling from dll. I tried this: Type comType = Type.GetTypeFromCLSID(new Guid("{95D4B070-6A73-11D5-95B0-0008C7E92339}")); object instance = Activator.CreateInstance(comType); But the second line fails, i dont know why!! might be some dependency, but anyway there should be a way!! Thank You
-
We didnt create this com dll file, we just have to use it and there are just one method call & one event handeling from dll. I tried this: Type comType = Type.GetTypeFromCLSID(new Guid("{95D4B070-6A73-11D5-95B0-0008C7E92339}")); object instance = Activator.CreateInstance(comType); But the second line fails, i dont know why!! might be some dependency, but anyway there should be a way!! Thank You
Shahin77 wrote:
But the second line fails
Standard question #1: What's the error message?? There's about a dozen reasons this can fail... I've found a rather good explanation of the pain you're about to put yourselve through here[^]. It's a 6 page article from back in 2002, but just about everything still applies today.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007modified on Wednesday, January 09, 2008 3:43:09 PM