Reputation: 235
I set up a class in project 1 that extends the WebViewPage so that I can add my own extension method. I followed this page: right here.
I have a second project that holds a class and an object. This project's .dll is referenced in project 1 and registered in gacutil.
The extension method uses the object that is in project 2. Whenever I go to use my newly implemented extension method on the page, I get the wonderful CCS0012 error.
CS0012: The type 'namespace.AppAuthentication.type' is defined in an assembly that is not referenced. You must add a reference to assembly 'namespace.AppAuthentication'
I have been able to debug through and see that the object has been setting correctly. Even when I parse it into JSON and display it to the console in jquery... everything is there! It is only when I access the object in the view.
Project 2 is referenced in project 1. Project 2's .dll is registered in my gacutil. The only way this works is if we set "copy local" to true on the reference. Except, this is not an acceptable option for me. I have been trying everything under the sun, and everything listed on this post: right here.
I would be extremely grateful if anyone can shed some light on this matter. To me, it seems Razor cannot access assemblies registered in GAC.
*edit: fixed title
Upvotes: 3
Views: 1248
Reputation: 235
After some time my co-worker found our solution. I was trying to add the namespace and what we needed was to add the assembly. This was done in the root web.config, not the views web.config. All we had to add was:
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="namespace.AppAuthentication />
</assemblies>
</compilation>
Now I am able to use my custom WebViewPage extensions!
Upvotes: 4
Reputation: 137
Assemblies registered in GAC will be loaded by .Net runtime while you are running the application.
You need to add reference to your project for successful build but you don't need to package it during the build and deployment process.
Upvotes: 0