views:

150

answers:

2

I'm in the process of creating a SharePoint web part that needs to use a single-threaded COM component. I've discovered that in order to make this work well, I need to add the AspCompat="true" directive to the page where the web part will live. The problem is I can't seem to set up such a page.

I created a new blank web part page via the regular browser interface, then added AspCompat to it using SharePoint Designer. But that causes it to become un-ghosted and the SafeMode parser says that directive isn't allowed. I then modified the blank web part page template to include the directive and created a new page, but got the same error.

I basically need to set up a page within my SharePoint site that is stored in the file system, has that directive, and can contain my web part. How would I go about creating such a page?

+1  A: 

I recently answered this question with some instructions that includes how to supply new site content page templates that you can use to host web parts. I think it's likely to work for you.

In your case, your aspx page template would have that AspCompat directive built-in.

Chris Farmer
Your answer to that other question seems promising. I figured I could just modify the existing feature manifest of my web part to include an ASPX page that contains AspCompat. When I went into the file containing the elements for my feature I could add another <module> element, but after I added a <file> element underneath it Visual Studio suddenly couldn't parse the package solution when in WSP View. The error it gave was 'Value cannot be null. Parameter name: path2'. Do I need to create a new feature within my web part just for the ASPX page?
Chris Tybur
OK, the error was caused by not including the Path attribute in the <file> element.
Chris Tybur
I ended up creating a new solution package containing a module being deployed as a feature, similar to what you suggested in your other answer. The solution installs correctly and seems to put things in the right place. I see my ASPX page with AspCompat in the Pages library, however, when I browse to it I still get a message saying the AspCompat directive isn't allowed. I set the content type for the file to GhostableInLibrary. I know it's looking at the disk file because if I rename it I can no longer browse to it. Why would it still have a problem with that directive?
Chris Tybur
A: 

According to Microsoft SharePoint developer support, it is simply not possible to use AspCompat within a SharePoint site. The SPPageParserFilter class, which is the one that disallows certain page directives, is apparently involved in processing all pages, even those that are on the file system. See this blog post for more details.

Chris Tybur