Solved

How to provide an additional/extra dll file when deployin a feature in sharepoint?

Posted on 2010-08-18
10
411 Views
Last Modified: 2012-05-10
In MOSS, I have a feature that has a receiver assembly and a receiver class specified. The receiver class extends SPFeatureReceiver. Inside the receiver class, I have implemented my code for the FeatureActived method.

My code inside the FeatureActivated method, is attaching an additional in-house dll to add an event to a given list.

In code it look similar to:
        MyList.EventReceiver.Add(SPEventRececeiverType.ItemAdding,
                                                    in-house-assembly, class-iniside-the-in-house-assembly)
 
where in-house-assembly contains teh assembly information and the class-inside-the-in-house-assembly is as per the name describes it.

So far, I have been able to make this solution to work on the condition that the additional in-house dll has been previously installed into the GAC (gacutil /if in-house-assembly.dll)

My question: is there any way I can provide the additional in-house dll as a file, module, resource or whatever other way, to the feature, and to make the feature to install this addditional dll int the GAC, before the FeatureActivated method being executed? If so, how can I achieve this?

Thank you in advance,


Edja
0
Comment
Question by:edgarmora4033
  • 6
  • 4
10 Comments
 
LVL 16

Expert Comment

by:raybies
ID: 33470840
Yes, your feature should be in a solution file (wsp), the solution file contains a manifest.xml, see code section.
There's an <Assemblies> node an under here you can add more dll's.
<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SolutionId="06da6001-f1b9-4f5e-82ad-fbc3939b067f" ResetWebServer="True" xmlns="http://schemas.microsoft.com/sharepoint/">
  <Assemblies>
    <Assembly Location="Services.SharePoint.tree.dll" DeploymentTarget="GlobalAssemblyCache"/>
    <Assembly Location="Services.SharePoint.FilterWebParts.dll" DeploymentTarget="GlobalAssemblyCache">
      <SafeControls>
        <SafeControl Assembly="Services.SharePoint.FilterWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2900282fd54adcc6" Namespace="Services.SharePoint.FilterWebParts" TypeName="*" Safe="True" />
      </SafeControls>
    </Assembly>
  </Assemblies>
  <FeatureManifests>
    <FeatureManifest Location="ContentConnector\feature.xml" />
    <FeatureManifest Location="CurrentPageFilter\feature.xml" />
    <FeatureManifest Location="DateFilter\feature.xml" />
    <FeatureManifest Location="QueryStringFilter\feature.xml" />
    <FeatureManifest Location="UserFilter\feature.xml" />
    <FeatureManifest Location="WebIDFilter\feature.xml" />
  </FeatureManifests>
</Solution>

Open in new window

0
 

Author Comment

by:edgarmora4033
ID: 33474863
raybies,

I am going to try your proposed solution. To me, it looks like it should work.

Question I have before Irying your proposed solution, is related with WSPBuilder. All my development has been done usiing WSPBuiilder. I do not find the manifest.xml file on my harddisk - I assume WSPBuilder removes the manifest.xml file as part of its cleanup process. So, do you know how can I achieve your proposed solution using WSPBuilder?

Thank you in advance,


Edja
0
 
LVL 16

Expert Comment

by:raybies
ID: 33481072
Event easier then just build the solution with your additional dll in the release folder.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:edgarmora4033
ID: 33481605
raybies,

I need to understand what you are saying. Are you telling me that if I copy my additional  
in-house-assembly inside the release folder of the project that activate the feature,without telling anything on configuration files to the feature project or registering the dll in the gac, the feature will  recognized and it will work? Should I register the in-house-assembly in the references of the feature project (the one built using WSPBuilder)? I truly think, if your solution works, it will be the cleaneest solution for my problem.

Let me know your comments asap.


Edja
0
 
LVL 16

Accepted Solution

by:
raybies earned 500 total points
ID: 33481717
There's 3 ways to do it, but here's the easiest.

1.- Ctrl + C (copy) you additional dll eg: myextra.dll
2.- Go to your project eg: C:\project\myBlah\sp.blah\bin\Release
Ctrl + V (paste)
3.- Open your project with VS
4.- Set the project to build "Release"
5.- In solution explorer, right click the Project > WSPBuilder > Build WSP

Your wsp will now have the additional dll

Tried and tested right now.

You can also add it as a reference with copy local
or create a new directory called GAC on the project root and copy your dll there.


0
 

Author Comment

by:edgarmora4033
ID: 33484763
raybies,

It worked perfect!

Thanks a lot.


Edja

P.S.: Last night I could not test because I did not have access to the machine that hosts my sharepoint development.

0
 

Author Closing Comment

by:edgarmora4033
ID: 33484800
Very clear instructions to follow.
Very helpful solution.

Thanks a lot!

Edja
0
 

Author Comment

by:edgarmora4033
ID: 33488626
raybies,

As a matter of technical interest, I would like you to add more info about the other 2 ways of getting same result.

I think another way will be configuring the library project to generate the release .dll file into the release folder of the WSPBilder project. Is this one of the other ways you were thinking? And which is(are) the other(s)?

Thank you,


Edja
0
 
LVL 16

Expert Comment

by:raybies
ID: 33489969
Edja, the other 2 ways:

1.- You can also add it as a reference with copy local
2.- create a new directory called GAC on the project root and copy your dll there.
0
 

Author Comment

by:edgarmora4033
ID: 33493712
raybies,

Thank you for your comments. First way I knew. Second one is new for me.

I appreciate this info.

Edja
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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