none
Deploying to the bin folder

    Question

  •  
    I have a sharepoint wsp solution that I've created, it installs great;
    to the GAC.

    When I change in the manifest.xml where it should put my files
    (DeploymentTarget="WebApplication") the solution gets added but will
    not deploy, complaining of missing dll files.  They're in the wsp
    file, in the same place they've always been, but they're not going into
    my site's bin folder like they should.

    Is there another step?  I tried manually copying them also, and
    googled for quite a while on this topic, everyone and their brother
    has a guide up on how to build a wsp, but none of the guides cover
    deploying to somewhere other than the GAC, except for one KB I found,
    which was how to deploy a web part, and that used a different
    mechanism (stsadm -o addwppack), which would not be appropriate for
    a wsp solution.

    What am I doing wrong?

    Monday, October 20, 2008 9:26 PM

Answers

  • No, FeatureReceivers need to be in the GAC as that seems to be the only place that SharePoint bothers to look for the assembly.  Go figures. 


    Eli
    Eli Van Eenwyk
    • Marked as answer by Mikey Jensen Tuesday, October 21, 2008 6:18 PM
    Tuesday, October 21, 2008 1:39 AM

All replies

  • are you creating your OWN DDF file? if yes please paste your one dll statement here which you have in DDF file. Secondly did you get missing file issue on all files or just some files etc.
    Monday, October 20, 2008 9:41 PM
  • I am creating my own ddf file.  The ddf file doesn't change between the two, the DLL files are going into the wsp for both situations.  If I explore the generated* wsp file from makecab as if it were a cab file (and it is), I can see all of my dlls in the bin folder.  The only literal difference between the two packages is the manifest.xml as I stated earlier.

    The only change in the manifest.xml file is this:

    Gac:
    <Assembly Location="bin\ReallyCoolDllFile.dll" DeploymentTarget="GlobalAssemblyCache" />

    Versus

    Bin:
    <Assembly Location="bin\ReallyCoolDllFile.dll" DeploymentTarget="WebApplication" />


    Edit:  Just to recap -- the GAC version works, the bin version doesn't.

    Edit: From the sharepoint logs, it looks like what is happening is that a FeatureReceiver is trying to call Assembly.Load -- but the file is never put in the bin folder so it's not getting found.  If I change it to GlobalAssemblyCache, the file gets put in the GAC, and Assembly.Load finds the file no problem.  Does "WebApplication" not work with FeatureReceivers?  In other words, do feature receivers get called before the files are copied?  That doesn't make any sense.  What else must be done besides changing the manifest to deploy to bin(WebApplication) instead of to the GAC?
    Monday, October 20, 2008 9:54 PM
  • No, FeatureReceivers need to be in the GAC as that seems to be the only place that SharePoint bothers to look for the assembly.  Go figures. 


    Eli
    Eli Van Eenwyk
    • Marked as answer by Mikey Jensen Tuesday, October 21, 2008 6:18 PM
    Tuesday, October 21, 2008 1:39 AM
  • featurereceiver dll should be in GAC but in general your issue is that you are expecting the dll to go in BIN folder. so here is what you need to modify in manifest, you only need to put the dll name here. however if you have created BIN folder in .WSP file (open wsp file in some ZIP software  or just rename to .zip and open it to see if your file has folder name as BIN on it. ) so set your DDF file with just dll name and update manifest also. this should fix your dll deployment to bin folder. 

    <Assembly Location="ReallyCoolDllFile.dll" DeploymentTarget="WebApplication" />
    • Proposed as answer by Moonis Tahir Wednesday, October 22, 2008 9:41 PM
    Tuesday, October 21, 2008 3:11 PM
  • Moonis:  My dll files ARE in a bin folder in the wsp.  It just made sense to organize my archive that way, put the bin files (dlls) in a bin folder, even when I was installing to the GAC.  Otherwise neither of the snippets above would work.  But as I already said "If I explore the generated* wsp file from makecab as if it were a cab file (and it is), I can see all of my dlls in the bin folder."  and I also stated "... the GAC version works, the bin version doesn't."  So it's obvious that the dll files are in my cab, and they're where I expect them to be.

    Also, I should note, that I tried moving them out of the bin subfolder and into the root of my wsp/cab file, and changed to the exact snippet you just posted in your latest reply, and it did not work (I tried this yesterday before I made my first post).

    So, in a final recap: Adding the solution *always* works, but while deploying the solution, I get the file IO exception thrown by assembly.load from my feature reciever, the dll files are never copied to my site's bin folder, and even if I copy them manually, it doesn't find them.

    Eli:  Thanks for the info;  if anybody figures out how to do this proper, please let me know.

    Tuesday, October 21, 2008 6:27 PM
  • is it possible that your ReallyCoolDllFile.dll has a reference to some dll which is not in GAC? if that is the case, you will need to push that 1st. Please note that when we write answers here, we write detail steps just as a double check that you can make sure that they exist the right way. i understood your bin folder in ddf but mentioned to check without bin by thinking if sharepoint has any issue with this reserved name. i always push dlls to bin without reserved names like "bin" but i did with other sub folder names. i do understand that it does not make any difference because those folder names are only for CAB files and has nothing to do with target folder. but this was just an extra check. i can see that it is not the case with your situation. any way lets move forward below.

    One more thing i can ask you is to verify where you are expecting your dll? 80/bin OR mysite website web application bin folder. if you are expecting it to mysite web application bin folder then most probably you are not deploying it to the required web application. you must check your deployment URL.

    • Proposed as answer by Moonis Tahir Wednesday, October 22, 2008 3:02 PM
    Tuesday, October 21, 2008 6:47 PM
  • is it possible that your ReallyCoolDllFile.dll has a reference to some dll which is not in GAC?

    No, I'm trying this with a dummy project, it literally has a single handler class with four overrides that do nothing

    1  
    2     public class HandlerClass : SPFeatureReceiver  
    3     {  
    4  
    5         public override void FeatureActivated(SPFeatureReceiverProperties properties)  
    6         {  
    7         }  
    8  
    9         public override void FeatureDeactivating(SPFeatureReceiverProperties properties)  
    10         {  
    11         }  
    12  
    13         public override void FeatureInstalled(SPFeatureReceiverProperties properties)  
    14         {  
    15         }  
    16  
    17         public override void FeatureUninstalling(SPFeatureReceiverProperties properties)  
    18         {  
    19         }  
    20  
    21     }  
    22  

     
    It works in the GAC, but not when I try to deploy it to WebApplication.  If I remove ReceiverAssembly/ReceiverClass from the feature.xml, it will work either way.  However, I did notice that the dll was going into my site's bin/bin folder instead of just the bin, so I moved the dll to the root of the cab, and that fixed it.  It seems that whatever path in your cab the dll is, it will try to retain that path when it goes to the bin folder.  So I fixed that, and still no go, works fine from the GAC but it will not even copy the assembly to the bin folder when I have a feature reciever.  :-/

    One more thing i can ask you is to verify where you are expecting your dll? 80/bin OR mysite website web application bin folder. if you are expecting it to mysite web application bin folder then most probably you are not deploying it to the required web application. you must check your deployment URL.

    The DLL gets copied to the 80/bin folder when there is no feature receiver, but when there is, it just never copies anywhere, and then the install dies.

    Please note that when we write answers here, we write detail steps just as a double check that you can make sure that they exist the right way.

    Sorry if I came off as rude, I guess that's the bottom line of trouble shooting: "But, are you sure the cable is really plugged in?"  It just seemed condescending and it was very frusterating.  I do appreciate the help.

    Wednesday, October 22, 2008 9:10 PM
  • Glad to see that it is fixed. so basically it is the same thing i was asking you that do it without BIN\assembly name and now you did it right. you were saying it will not work but you can see now that was the right fix. When you specify assembly location this way
    <Assembly Location="ReallyCoolDllFile.dll" DeploymentTarget="WebApplication" />
    now it goes to bin folder. if this is correct, please mark my second reply as answer which is the correct fix for your situation. Thanks
    Wednesday, October 22, 2008 9:40 PM
  • You didn't really solve his situation, I believe Eli's answer is correct. I had the same issue, where i could not get a Feature to find the FeatureReceiver assembly when i deployed via the WebApplication instead of the GAC. I correctly used the Assembly Location="MyDllName" DeploymentTarget="WebApplication" /> line in my manifest and had the dll in the root of the solution file. However it was still unable to load the event receiver assembly and the dll did not deploy.

    To test if the feature failed to install because of a timing issue, I then created two solution files one with just my assembly and one with just the feature. I was able to add and deploy the solution that contained just the assembly. I was able to add the solution with the feature, but was unable to deploy it. I received an error that the assembly could not be loaded. I even attempted to manually install the feature through stsadm, verifying that the assembly was in the bin for the web application and it failed.

    Eli's answer seems to be the correct one. And thinking about it sort of makes sense. The feature is installed at a farm level where all web applications can access it. If the assembly were deployed specific to just one web application the feature would fail when used at all others. So it would seem that the FeatureReceiver needs to be deployed to the GAC. Just wish that was documented somwhere.
    Thursday, November 13, 2008 2:47 PM