I have been testing out some few things with VS2013 Native Tools Command Prompt.
So far, I couldn't get my code to load dlls that I made.
Here is my dll code, written in c. (Based on msdn example)
int __declspec(dllexport) SampleMethod(int i){return i*-10;}
And compiled it with cl /LD in VS2013 Native Tools.
Then I compiled my c# code with csc in VS2013 Native Tools.
public class MainClass
{
static void Main(string[] args)
{
Assembly assembly;
try
{
assembly = Assembly.Load(args[0]);
Console.WriteLine("Loaded dll");
}
catch (Exception e)
{
Console.WriteLine("Exception caught : \n{0}.", e);
}
}
}
And the exception caught goes as :
Exception caught :
System.BadImageFormatException: Could not load file or assembly 'test' or one of
its dependencies. The module was expected to contain an assembly manifest.
File name: 'test'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String cod
eBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&
stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntro
spection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName as
semblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMar
k& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIn
trospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evid
ence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolea
n forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evid
ence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at MainClass.Main(String[] args)
I have tried in both x86 and x64 tools and now I'm out of ideas.