dicksmithauto
asked on
Reference to Microsoft.SharePoint.Publishing not working (GAC issue?)
In a WebPart that I am creating I load a User Control using LoadControl() -- this User Control makes use of some of the objects defined in Microsoft.SharePoint.Publi shing. However...
After loading the control using LoadControl() (with the reference):
The type or namespace name 'Publishing' does not exist in the namespace 'Microsoft.SharePoint' (are you missing an assembly reference?)
The first time I saw this error I knew immediately that I had forgotten to include the reference in my wrapper web part. After including it & rebuilding/deploying I still got this error. I then decided to try and manually copy my solution to the GAC (with the reference). The following is what resulted:
Exception When Trying To Copy My Solution To GAC (using wspbuilder):
System.BadImageFormatExcep tion: The module was expected to contain an assembly manifest (Exception from HRESULT: 0x80131018)
at System.Runtime.InteropServ ices.Marsh al.ThrowEx ceptionFor HRInternal (Int32 errorCode, IntPtr errorInfo)
at System.GACManagedAccess.As semblyCach e.InstallA ssembly(St ring assemblyPath, InstallReference reference, AssemblyCommitFlag flags)
...
If I remove the assembly reference to Microsoft.Sharepoint.Publi shing I can copy to the GAC with NO problem . What could be causing this? Is my dll corrupt? If it is how do I repair/replace it? Is there a way to include the reference in my user control? Am I missing something obvious? I am at a loss here.
I've tried changing the targets to x86 and x64, but currently it's on Any CPU. The workstation is a 64bit machine running x64 MOSS.
Note: One thing I have noticed is that the Publishing DLL a different solution is referencing is not located in the GAC and has a modified/create date of about 6 months prior to the version in the GAC. They both have the same version numbers and are exactly the same size, however. I have tried referencing this DLL instead of the GAC'd one, but with no luck or even a different outcome.
After loading the control using LoadControl() (with the reference):
The type or namespace name 'Publishing' does not exist in the namespace 'Microsoft.SharePoint' (are you missing an assembly reference?)
The first time I saw this error I knew immediately that I had forgotten to include the reference in my wrapper web part. After including it & rebuilding/deploying I still got this error. I then decided to try and manually copy my solution to the GAC (with the reference). The following is what resulted:
Exception When Trying To Copy My Solution To GAC (using wspbuilder):
System.BadImageFormatExcep
at System.Runtime.InteropServ
at System.GACManagedAccess.As
...
If I remove the assembly reference to Microsoft.Sharepoint.Publi
I've tried changing the targets to x86 and x64, but currently it's on Any CPU. The workstation is a 64bit machine running x64 MOSS.
Note: One thing I have noticed is that the Publishing DLL a different solution is referencing is not located in the GAC and has a modified/create date of about 6 months prior to the version in the GAC. They both have the same version numbers and are exactly the same size, however. I have tried referencing this DLL instead of the GAC'd one, but with no luck or even a different outcome.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That worked for me. Thanks for the information.