I have a C# dll
, with some methods, which I am trying to access in my native project with /CLR
support.
I reference this DLL
using a #using
directive, and the DLL
is recognized and the project compiles.
However, during runtime, I get a FileNotFoundException
, which is pretty weird since the DLL is present in the source directory of the project.
TheDLL
is compiled inVS 2015
with .NET Version 4.5.2
. Since I have CLR
support on my C++ mixed, I have edited the project file to make TargetFrameworkVersion
as 4.5.2, but still the runtime
does not work.
Kindly advise on what could be the issue?
EIDT - ADDED SOME CODE
C#
namespace TestManagedLibrary
{
public class Class1
{
public int i;
public Class1()
{
i = 5;
}
public int returnValue()
{
return i;
}
}
}
C++/CLI
#using <TestManagedLibrary.dll>
using namespace System;
using namespace System::Runtime::InteropServices; // Marshal
using namespace TestManagedLibrary;
ref class ManagedFoo
{
public:
ManagedFoo()
{
Console::WriteLine(_T("Constructing ManagedFoo"));
Class1 ^testObject = gcnew Class1();
int a = testObject->returnValue();
}
};