This is so silly but I just figured out how to do it and I had to post it (in case someone else is as brain dead as I was).
When you want to add an existing file to your current project in Visual Studio that's located outside the current project's directory, that file is copied into the project folder, then it's added to the project.
Well what if you don't want a duplicate file?
Maybe you want to share the same source file in multiple projects so that if you modify the code in one project (to fix a bug, for example) the updated code is immediately available to the other projects.
I know, I know, most of us would create some sort of shared library for this code and just reference this DLL or even the whole VS project, but to add a shared file all you need to do is instead of clicking the 'Open' button when adding an existing file, click the arrow to the left of this button. Then select 'Link File' from drop down, this way you create a link to the original file without coping it locally.
Monday, July 12, 2010
Friday, January 15, 2010
I am doing some custom SharePoint 2007 Workflow development utilizing WSPBuilder and I had this one workflow that just would not run no matter what I did. I disabled all the activities in it except a Workflow History logging activity but still the workflow would not start. I am a little embarrassed to say this was driving me insane for the better part of a day.
No matter what I did when I ran the workflow I would get
I searched through the SharePoint logs over and over again and all I was seeing was unable to load workflow assembly, but I knew it would load since I had other workflows in this library and they all ran no problem.
Here is the error message out of the log file, I hope you spot the problem:
Load Workflow Assembly: System.IO.FileLoadException: Could not load file or assembly 'com.XXXX.Sharepoint.Workflows\, Version\=18.104.22.168\, Culture\=neutral\, PublicKeyToken\=$PublicKeyToken$' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) File name: 'com.XXXX.Sharepoint.Workflows\, Version\=22.214.171.124\, Culture\=neutral\, PublicKeyToken\=$PublicKeyToken$' at System.Reflection.AssemblyName.nInit(Assembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at ...
Well that part I was not seeing was PublicKeyToken\=$PublicKeyToken.
It turns out that when I created the feature using the WSPBuilder create SyncSharePointWorkflow option it must have had an error I did not notice and this error caused it not to add the PublicKeyToken to the elements.xml file. Or maybe it never did and I just forgot to update this line.
CodeBesideAssembly="com.XXXX.Sharepoint.Workflows, Version=126.96.36.199, Culture=neutral, PublicKeyToken=$PublicKeyToken$"
Anyway once I added the correct Public Key, retracted and redeployed the workflow, it ran fine.
Hope this helps someone else save a day!!!