1
votes

I am working on visual web parts. I created a sharepoint project in VS2010 and added one visual web part to it.Built this and deployed.I am able to see the web part added and I can drag that to any page on site.

Now I created a new solution redirecting to same site (site to which first solution was pointing). Added one visual web part to it.Built this and deployed too.now when I see the site though I can add this new webpart to the page but the webpart added from previous solution are throwing error.

Web Part Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type TestWebPart1.Testwebpart.Testwebpart, TestWebPart1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=02dc69d4b9065085 could not be found or it is not registered as safe.

Looks Like I can not work with more than one solution for a single site. May I get the reason for this?

3

3 Answers

0
votes

I'm not sure if it's the case but; here's an theory:

You may have created the webparts with the same namespace and name but within different solutions.

So what is going on is; the first solution gives the webpart's binary a unique id like "1" and the other one is giving "2" for instance.

So the first deployed web part's binary is overwritten with the binary with Id = "2" since they have the same names, but the unique Id of the binary is the newer one's id.

So the first one's controls are looking for a binary with Id = "1" and cannot find it. That may be the error you're receiving.

You've got to change the names. If this is the case, let me know and I'll add some comments on the naming conventions you can use.

0
votes

This usually means your webparts assembly isn't registered among the safecontrols in the sharepoint web.config OR that you didn't create a strongly typed assembly

To register in safecontrols

To fix open your web.config located in the iis root site of your sharepoint server, usual path is something like

c:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config

Add the following in the <SafeControls> section

 <SafeControl Assembly="TestWebPart1.Testwebpart.Testwebpart, TestWebPart1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=02dc69d4b9065085" Namespace="TestWebPart1" TypeName="*" Safe="True" AllowRemoteDesigner="True" />

Signing assemblies

http://msdn.microsoft.com/en-us/library/ms247123(v=vs.80).aspx

-1
votes

Its not very clear what you are trying to achieve.

But you can have as many solution as you want for a site. There is no 1 solution restriction