Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reference to Microsoft.SharePoint.Publishing not working (GAC issue?)

Posted on 2009-03-31
3
Medium Priority
?
3,325 Views
Last Modified: 2012-05-06
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.Publishing. 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.BadImageFormatException: The module was expected to contain an assembly manifest (Exception from HRESULT: 0x80131018)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.GACManagedAccess.AssemblyCache.InstallAssembly(String assemblyPath, InstallReference reference, AssemblyCommitFlag flags)
...

If I remove the assembly reference to Microsoft.Sharepoint.Publishing 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.
0
Comment
Question by:dicksmithauto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
Jason Evans earned 1000 total points
ID: 24031459
Hi there.
From experience, when I've referenced the Microsoft.SharEPoint.Publishing DLL, I usually reference it from here:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\isapi
I've never referenced this DLL in the GAC. You could try using the DLL from this location instead.
Cheers.
Jas.
0
 

Expert Comment

by:EIT-Midmark
ID: 24861991
That worked for me.  Thanks for the information.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question