views:

433

answers:

2

Hello:

Is it possible to have two Web Parts with the same DLL, but two .webpart files, deployed in Sharepoint at the same time?

Background : I am developing an application that will generate a ".cab" file containing a Web Part (ASP.NET 2.0 Web Part). After that, the user should be able to deploy this ".cab" file in a in a SharePoint server.

My application already includes the DLL of a Web Part. The "behavior" of this Web Part depends on the properties of the ".webpart" file which will be generated at runtime by my application (its content will change depending on certain user choices) After generating the ".webpart" file, it packages it to a ".cab" file along a Manifest.xml and the DLL.

Imagine that the user creates two "cab" files using my application. And he wants to deploy them into SharePoint.

To test this, I create this two ".cab" files with my app, and in SharePoint I execute:

$> STSADM.EXE -o addwppack <cab filename #1>
$> STSADM.EXE -o addwppack <cab filename #2>
$> STSADM.EXE -o deletewppack <cab filename #1>

After the execution of the third command, the Web Part #2 doesn't have the DLL. When I installed Web Part #2, SharePoint override the DLL file of Web part #1 The problem here is that the DLL of both files is copied to same location. That location is the Assembly name of DLL. That assembly name cannot be changed without recompiling again (I think).

Is there anyway to deploy two cab files independently, even if they share the same DLL?

A: 

You could split your application in 2 parts: a 'library' that contains only your dll. And something that deploys the .webpart file only. Users must always keep the 'library' part installed..

Also, you might want to look at alternatives from installing a 'wpppack'.. the .webpart file is nothing more than a file in a library in your sites.. may be easier to add that than to install a .cab on the server.

ArjanP
A: 

This shouldn't be an issue at all. A .webpart file simply points to a class within an assembly, and provides the configuration values for a specific instance of that class. If you want to have multiple configurations of your webpart available from the webpart gallery, you would go about it by uploading multiple .webpart files which reference the same class. For example, every instance of the listview webpart can be exported to a .webpart file, but they are all using the same webpart class. Check this blog posting for more info on the contents of the .webpart file.

OedipusPrime