ITWorker ITWorker - 1 year ago 77
C# Question

Assembly.LoadFrom {"Illegal characters in path."} error

I have the following declaration:

Assembly SampleAssembly;
SampleAssembly = Assembly.LoadFrom("\bin\mycppapp.dll");

where the bin folder is inside an ASP.NET MVC 5 project structure and it contains the mycppapp.dll file, which is a Visual C++ entity with various methods. When the code processes this line, I see in the debugger the following error:

{"Illegal characters in path."}

What can I do to fix this?

Thank you.

Answer Source

In C, C++ and C#, the backslash (\) is an escape character. For example, \r\n signifies a carriage-return, line-feed pair.

Use two backslashes to insert a single one.

Assembly SampleAssembly;
SampleAssembly = Assembly.LoadFrom("\\bin\\mycppapp.dll");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download