.NET Framework Bookmark and Share   
 index > Common Language Runtime > unable to find assembly
 

unable to find assembly

Hi,

I am new to COM and is trying to build a simple c dll that calls managed code but when I create the CDLL and run it I get the error "Unable to find assembly". We have an MiddleTier project written in managed code(mainly C#)with multiple projects, however we must create a dll using unmanaged code(using c) that talks to this layer.Originally this code is launchedvia an exe. To simplify things I created a managed library(bridge code)that talks to this MiddleTier Layer. Use regasm to create tlb file and set the assembly as COM visible. I have also created a c dll that calls the managed code. To test this I created a console application that loads the dll but when I debug into it I get unable to find assembly for the managed code. Do I also need to make the managed code COM visible or is there another step that needs to be done? Is there an alternate way that I can accomplish this? Any advice is appreciated.

Thanks,

//This is the call in the CDLL
__declspec

(dllexport)

(dllexport)

double GetStartFrequency()

{

HRESULT hr = CoInitialize(NULL);

IManagedClassPtr pICalc(

__uuidof(ManagedClass));

double result = 0.0;

pICalc->GetStartFrequency(&result);

CoUninitialize();

return result;

}

//This is bridge class that talks the MiddleTier layer. A reference is added to this project

public

class ManagedClass : IManagedClass

{

MT.ISystem systemControl =

null;

public ManagedClass()

{

this.Initialize();

}

public void Initialize()

{

IObjectFactory objectFactory = RootFactory.Instance.GetFactory("");

try

{

systemControl = objectFactory.GetSystemControl(

"");

objectFactory.DeserializeSetup();

systemControl.StartSystem();

}

catch (Exception ex)

{

throw ex;

}

}

public int Add(int Number1, int Number2) //for testing

{

return Number1 + Number2;

}

public double GetStartFrequency()

{

return systemControl.StartFreq;

}


jStarZone
You probably forgot to put the C# assembly in the GAC. Use the Regasm.exe /codebase option if necessary. It could be an issue with locating dependent assemblies too, use fuslogvw.exe to troubleshoot that.

Hans Passant.
nobugz
You probably forgot to put the C# assembly in the GAC. Use the Regasm.exe /codebase option if necessary. It could be an issue with locating dependent assemblies too, use fuslogvw.exe to troubleshoot that.

Hans Passant.
nobugz

You can use google to search for other answers

Custom Search

More Threads

• Referencing meta assembly.
• Developing in .NET/C# versus ATL/C++
• What is the right way to dispose Control instances?
• Help With DllImport Sigs
• Logs in Windows Vista
• Marshalling an array
• Garbage Collection information with .Net controls hosted in IE?
• Method does not have an implementation.
• Accessing VARIANTs from c#
• Are static variables thread-safe?