I have a SharePoint project (named MyProject for this example) with an Application Page that references the namespace System.Collections.Generic. When I try to deploy the project, I get this error message.
Cannot add the specified assembly to the global assembly cache: MyProject.dll
If I remove the reference to System.Collections.Generic, it works fine.
I looked in the GAC on the SharePoint server, and the System.Collections.Generic DLL is not there! I assume that is the cause of my problem. How do I fix it?
EDIT: I just removed the solution, using the Central Admin web page. Then, I used the sharepoint commands Add-SPSolution and Install-SPSolution to install it again. That worked. The deployment was successful. The System.Collections.Generic DLL is still not in the GAC, as far as I can tell. That seems strange to me. I'm looking in C:\Windows\assembly. Is there another place this DLL could be?
EDIT 2: I made a small code change and tried to update the solution, using Update-SPSolution. The error is back. I tried removing from the Central Admin page, and adding and installing, as above. I still got the error.
To fix it this time, I did this:
- Removed the solution using the Central Admin page.
- Rebuilt the solution WITHOUT the reference to System.Collections.Generic.
- Added and installed the solution using Add-SPSolution and Install-SPSolution.
- Rebuilt the solution WITH the reference to System.Collections.Generic.
- Updated the solution using Update-SPSolution.
I am glad to have a workaround, but this is not an ideal process. Is there something I can do to fix this problem?
EDIT 3: If I remove the solution before I get an error, it seems to be easier to get it to work. In that case, instead of running Update-SPSolution, I should just remove it using Central Admin, and then run Add-SPSolution and Install-SPSolution. It works, but I would still like to know what is going on.
EDIT 4: I found a possible cause and solution. I had been building the WSP file by running this command in the Developer Command Prompt:
msbuild MyProject.csproj /p:IsPackaging=True
However, if I instead right click on the solution in Visual Studio and select "Deploy", I don't seem to have any problems with deploying. I'll play around with it some more, but so far it looks promising.
What is the difference between that command and selecting "Deploy" in Visual Studio?