Assembly Probing
-
Currently, I'm working on COM Interoperability project. In that client application (in vb 6.0) need to launch my application developed in .net. Now the problem is the assemblies referenced by my .net application is spread across 2-3 folders and not in the same folder where my .net executable is placed. Also, the client application is also not in the same path where my .net executable is. If I keep everything (i.e. .net executable and client application) in same location everything works fine but if I move my client application to location different than my .net executable path, client application fails to load. I register the assembly into the registry withoug codebase. Also, I tried setting the private path in probing attribute in app.config file but it didn't work. I want to avoid making my .net component assembly as shared assembly. Can any one pls help in how I can resolve the assembly reference issue? Thanks...
-
Currently, I'm working on COM Interoperability project. In that client application (in vb 6.0) need to launch my application developed in .net. Now the problem is the assemblies referenced by my .net application is spread across 2-3 folders and not in the same folder where my .net executable is placed. Also, the client application is also not in the same path where my .net executable is. If I keep everything (i.e. .net executable and client application) in same location everything works fine but if I move my client application to location different than my .net executable path, client application fails to load. I register the assembly into the registry withoug codebase. Also, I tried setting the private path in probing attribute in app.config file but it didn't work. I want to avoid making my .net component assembly as shared assembly. Can any one pls help in how I can resolve the assembly reference issue? Thanks...
Have a look at the AssemblyResolve event on the application domain AppDomain class. This event is called when finding an assembly location fails; you should be able to hook this and load the assembly from whatever location you like. A quick google on that event gives a few examples.
Mark Churchill Director Dunn & Churchill
-
Have a look at the AssemblyResolve event on the application domain AppDomain class. This event is called when finding an assembly location fails; you should be able to hook this and load the assembly from whatever location you like. A quick google on that event gives a few examples.
Mark Churchill Director Dunn & Churchill
Mark, Thanks you very much for your reply. I was looking for some direction to resolve my problem which you very well provided. However, Let me elaborate more on my problem. In my case, there are two different applications, one developed in vb 6.0 (which acts as COM client) and other in .net. Now I register my .net application with registry (using regasm tool but without using /codebase switch). Also, I don't put my .net component (which COM client will access) into GAC. So in this case when I try to access my .net component from VB application using COM, VB application fails to locate my .net component and its dependancy. Can you tell me what I should do in order to make my vb application know where my .net component is placed. If I put my vb application and .net application together, everything works fine. But if I put them seperately, loading fails with the message that "Runtime error '429'. ActiveX Comoponent can't create object.". In my vb code, I'm using CreateObject to create my .net component object. ----------------- Private Sub Command1_Click() Dim i As Object Set i = CreateObject("TestApp.class1") (TestApp.class1 is my .net component) i.ShowMessage End Sub ----------------- I hope I have explained my problem properly. if you have questions on this pls revert back. Thanks......
-
Mark, Thanks you very much for your reply. I was looking for some direction to resolve my problem which you very well provided. However, Let me elaborate more on my problem. In my case, there are two different applications, one developed in vb 6.0 (which acts as COM client) and other in .net. Now I register my .net application with registry (using regasm tool but without using /codebase switch). Also, I don't put my .net component (which COM client will access) into GAC. So in this case when I try to access my .net component from VB application using COM, VB application fails to locate my .net component and its dependancy. Can you tell me what I should do in order to make my vb application know where my .net component is placed. If I put my vb application and .net application together, everything works fine. But if I put them seperately, loading fails with the message that "Runtime error '429'. ActiveX Comoponent can't create object.". In my vb code, I'm using CreateObject to create my .net component object. ----------------- Private Sub Command1_Click() Dim i As Object Set i = CreateObject("TestApp.class1") (TestApp.class1 is my .net component) i.ShowMessage End Sub ----------------- I hope I have explained my problem properly. if you have questions on this pls revert back. Thanks......
Ah, sorry I assumed it was the .net client couldnt locate it's dependancies. I'm a bit rusty on my COM skills, have you tried checking under HKEY_CLASSES_ROOT\CLSID to see if its been registered correctly? Otherwise you might have to use the /codebase option... Good luck ;)
Mark Churchill Director Dunn & Churchill
-
Ah, sorry I assumed it was the .net client couldnt locate it's dependancies. I'm a bit rusty on my COM skills, have you tried checking under HKEY_CLASSES_ROOT\CLSID to see if its been registered correctly? Otherwise you might have to use the /codebase option... Good luck ;)
Mark Churchill Director Dunn & Churchill
Mark, It seems now you have understood the problem correctly. I can not use /codebase switch as my assembly is not strong named assembly (there are some issues because of which I can't make my assembly strong named). You can supply /codebase options only with the assembly which are strong named. Thanks....
-
Mark, It seems now you have understood the problem correctly. I can not use /codebase switch as my assembly is not strong named assembly (there are some issues because of which I can't make my assembly strong named). You can supply /codebase options only with the assembly which are strong named. Thanks....
Hmmm if you can't use strong naming then I'm really not sure. Maybe someone else has some ideas? :/
Mark Churchill Director Dunn & Churchill