473,657 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CLR Runtime not finding an assembly even though it is loaded and running

1 New Member
OS: Windows XP (32 bit)
NET: .Net 2.0 runtime
DevEnv: VS 2008 C++ and C#

I am attempting to use an unmanaged C++ library to load a managed C# assembly and hand off control. I have the following in my C++ routine:

Expand|Select|Wrap|Line Numbers
  1. ICLRRuntimeHost*        Clr = NULL;
  2. HMODULE                 hMsCorEE = LoadLibraryA("mscoree.dll");
  3. PROC_CorBindToRuntime*  CorBindToRuntime = (PROC_CorBindToRuntime*)GetProcAddress(hMsCorEE, "CorBindToRuntime");
  4.  
  5. CorBindToRuntime(NULL, NULL, CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (void**)&Clr));
  6.  
  7. ClrHost->Start();
  8.  
  9. Clr->ExecuteInDefaultAppDomain("MyLib", L"MyNamespace.MyClass", L"MyMethod", MyParams, &RetVal);
  10.  
This code is actually working in that the library is being loaded and my class.method is executed. However in my method there is code that is attempting to de-serialize some of the data being passed in as the parameter string which is throwing an exception as follows:

System.Runtime. Serialization.S erializationExc eption: Unable to find assembly 'MyLib, Version=2.5.0.5 , Culture=neutral , PublicKeyToken= 4b580fca19d0b0c 5'.

Even though the code that was executing at the time of the exception was the very library that is not being found.

I did some testing to determine what the runtime believes the full name of the currently executing assembly to be and I got the following depending on the method I used to retrieve it:

CODE:
Expand|Select|Wrap|Line Numbers
  1.             Assembly SampleAssembly;
  2.             Int32 Integer1 = new Int32();
  3.             Type Type1;
  4.            SampleAssembly = Assembly.GetAssembly(Integer1.GetType());
  5.             file.WriteLine("FullName=" + SampleAssembly.FullName);
  6.  
Output:

FullName=mscorl ib, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9

CODE:
Expand|Select|Wrap|Line Numbers
  1.             Type t = typeof(System.Data.DataSet);
  2.             file.WriteLine("FullNameAgain=" + t.Assembly.FullName.ToString());
  3.  
Output:

FullName=System .Data, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9

I have seen sparse reference to potential complications resulting from the method CLR uses to locate assemblies, but nothing is clear as to how I can overcome this, other then having MyLib registered in the GAC which does bypass the problem. However, I am trying to eliminate the need to manage the code in the GAC. It would seem that I am missing something since I am able to load and run the managed code, but the library name is not being loaded with the assembly (or at least not correctly)...

Any ideas would be appreciated.

Thanks.

creo
Nov 17 '08 #1
0 1704

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4809
by: Outshined | last post by:
I have a class library where just about every class uses its static initializer to register with a central registry object in the same assembly. I am hoping for some sort of Assembly.Load event that I can handle to go through my assembly and invoke the static initializer on each relevant class. This way, everything that needs to be registered will be registered before the first request to the registry object. So my questions are:
2
240
by: Mike Talbot | last post by:
Hello I've got a windows service checking every x minutes (Timer) on a job. The job execution takes place in a separate assembly that is called in the timer_elapsed event. After the job has stopped the job-assembly is still loaded somehow, means I can not exchange it while the service is
1
1971
by: Kent Rollins | last post by:
I am writing a server and an MMC console app that use remoting to talk to each other. The MMC client and the server share a couple of assemblies: one has the interface that is remoted from the server and the other has some data structures that are passed across the remoted interface from the server to the client. These assemblies are not strong named and are not entered in the GAC. I could easily solve this problem by putting the DLL in...
5
1300
by: jon morgan | last post by:
Hi, I am trying to clean out all the VB specific code in a project before porting to C#. Having removed all the import references I still see the VB runtime is loaded at startup. How can I pin down what is actually causing the VB runtime still to load? Thanks for any help.
2
7107
by: Robb Sadler | last post by:
I am trying to write several hardware interfaces that would use the same base class and functions and be implemented differently. I don't want to ship all of the interfaces, but want to access them using the same generic base class. I have seen that I can use the Assembly.load method to load the implementation I need for the hardware being connected to, but wish to write the code such that I can reference the methods of the class...
8
2012
by: Rick Strahl [MVP] | last post by:
Hi all, I'm building an app that uses the ASP.Net runtime... One problem I've run into is that pages running inside of the runtime are not finding DLLs in the GAC. In fact, if I look at the debug trace of the search path it searches the bin directory and Temporary ASP files but not the GAC. A simple example I used was trying to load System.Windows.Forms. If I add a
7
6953
by: yuanlinjiang | last post by:
I am working on converting a win32 console application from VC6 to VC7. My version is Microsoft Development Environment 2003 version 7.1.3088. The code works fine on VC6. it is a console program for scientific computation, so it has nothing to do with MFC. But it needs some other libraries such as MKL, sparselib, etc. VC7 can build the executable successfully. However, when i run it, there is only one line on the command window:
5
1844
by: Luis Arvayo | last post by:
When I load an assembly at runtime, that is to say, a plugin DLL through Assembly.Load, an old version of the assembly is loaded. If I recompile the DLL and then copy the result to where the assembly is loaded by the main app, anyway, the old assembly is used. From where ?, I don't know. I don't have an error here. Checked several times, because if I delete the assembly, at runtime it is not detected by the Directory.GetFiles() method. It...
4
2188
by: Per Bolmstedt | last post by:
(This question has been asked previously in this group, but I don't think it was ever really properly answered.) I want to use reflection - preferably - to find all Web Forms in my web site that inherit my base page class (which in turn inherits System.Web.UI.Page). Behold the following code: For Each asm As System.Reflection.Assembly In System.AppDomain.CurrentDomain.GetAssemblies() For Each mdl As System.Reflection.Module In...
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.