This question might be a little odd, but is there any specific way to import a C++ reference into an ASP.NET C# project?
The problem I am having is that VS is giving me the following error:
Error CS0246 The type or namespace name 'LicenseAdminApi' could not be found >(are you missing a using directive or an assembly reference?)...
This error only shows up within my Views and not in my Controller or any .cs code, The code within my views where I reference fields defined within the DLL also work without any issues. And the project compiles/builds and runs as expected without any issues.
LisenseAdminApi is a DLL also written by our company, just in a different department and it was developed in C++. It requires a Visual Studio 2015 C++("Microsoft Visual C++ 2015 Redistributable (x64) - 14.0.23918") runtime to run. I also had to change my project to run in x64 and use the x64 version of IIS. Without installing it I get the following error when I try and run the project:
Server Error in '/' Application.
Could not load file or assembly 'LicenseAdminApi.DLL' or one of its >dependencies. The specified module could not be found. Description: An unhandled exception occurred during the execution of the >current web request. Please review the stack trace for more information about >the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or >assembly 'LicenseAdminApi.DLL' or one of its dependencies. The specified module >could not be found.
Similar to the error VS is giving me within the error list, which makes me think that it's not using the runtime within VS to read the DLL until the project is compiled. It's quite odd because like I said the project builds fine and runs without any issues once the runtime is installed, but the error in the error list is not going away and I need to sort it out as company policy is not to commit any code with errors.
Edit If I were to add the "@using LicenseAdminApi" to the view, it also gives me the same error in the error list. Not really sure what solution to try if any as I don't really know what's wrong to begin with.
The usage of the DLL is not the issue, I can call the methods I need and they work. The problem is that VS is giving me an error that seems to not exist when I build and run my project. Apart from the standard way of adding a reference which I assume everyone knows, is there anything I need to enable for VS to read the C++ DLL before compiling?
Within my Views/Web.config I have included my namespace like the following:
<system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> ... <add namespace="LicenseAdminApi" /> </namespaces> </pages>
Which according to me should make the namespace available in my views, but it doesn't.
Once again the code is running fine and my project is building, it is only when I am not debugging that VS is telling me that my type/namespace could not be found. This also only occurs within my views, within my controllers I can reference the namespace without getting an error. Even though I do get the error in VS the code and my views all run perfectly when I debug
Please let me know if anyone needs more details, I have tried many different solutions including all the answers provided here
Thanks in advance