|
|
||||||
|
#1
|
|
|
|
|
Hi there,
I want to move the document to second document library (portal level) as soon as its been submitted (insert as eventListType) to first document library (WSS level). I do have assembly registered at GAC. I am able to add the Name, version and PublickKeyToken to the advance settings of document library. Error I see in event viewer is: ------------------------------ Unable to instantiate event handler (assembly "WorkFlowC,Version=1.0.1753.30479,Culture=Neut ral ,PublicKeyToken=b87bf9d85439e671", class "WorkFlowC.Engine1"), or report event for "Working docs/spnewlisting.aspx" in "Working docs". Error in the application. ------------------ Please see the code below. ------------------- using System; using System.Windows.Forms; using System.Security.Principal; using System.Runtime.InteropServices; using Microsoft.SharePoint; using Microsoft.SharePoint.Portal.SingleSignon; namespace WorkFlowC { /// <summary> /// Summary description for Class1. /// </summary> public class Engine1:IListEventSink { public void OnEvent(SPListEvent listEvent) { // Call MSSO string[] strCredentials=null; Credentials.GetCredentials (Convert.ToUInt32 (1),"WorkflowC",ref strCredentials); string User = strCredentials[0]; string Domain = strCredentials[1]; string Password = strCredentials [2]; //Create new context WindowsImpersonationContext windowsContext = CreateIdentity ("mgaur","AU","test1").Impersonate(); //Get event objects SPWeb eventSite = listEvent.Site.OpenWeb(); SPFile eventFile = eventSite.GetFile(listEvent.UrlAfter); SPListItem eventItem = eventFile.Item ; //Dtermine if document submitted if(listEvent.Type == SPListEventType.Insert) //Move the document eventFile.MoveTo ("http://dais-net:7554/test/Forms/AllItems.aspx",false); windowsContext.Undo(); } protected static WindowsIdentity CreateIdentity(string User, string Domain, string Password) { // The Windows NT user token. IntPtr tokenHandle = new IntPtr(0); const int LOGON32_PROVIDER_DEFAULT = 0; const int LOGON32_LOGON_NETWORK = 3; tokenHandle = IntPtr.Zero; // Call LogonUser to obtain a handle to an access token. bool returnValue = LogonUser(User, Domain, Password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, ref tokenHandle); if (false == returnValue) { int ret = Marshal.GetLastWin32Error(); throw new Exception ("LogonUser failed with error code: " + ret); } System.Diagnostics.Debug.WriteLine ("Created user token: " + tokenHandle); //The WindowsIdentity class makes a new copy of the token. //It also handles calling CloseHandle for the copy. WindowsIdentity id = new WindowsIdentity(tokenHandle); CloseHandle(tokenHandle); return id; } [DllImport("advapi32.dll", SetLastError=true)] private static extern bool LogonUser (String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); [DllImport("kernel32.dll", CharSet=CharSet.Auto)] private extern static bool CloseHandle (IntPtr handle); } } ------------------ |
|
|
|
#2
|
|
|
|
|
Hi Manish,
After reviewing your code, I'd suggest you can comment the code line "Credentials.GetCredentials(Convert.ToUInt32(1),"W orkflowC",ref strCredentials);" Since you have performed the impersonation, from my view, this line is unnecessary. From the error, it appears that WSS can't instantiate the assembly. Please ensure your assembly version code of document library is the same to the one in the GAC. Look forward to your trouleshooting result! Best Regards, Wei-Dong Xu Microsoft Product Support Services Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
|
#3
|
|
|
|
|
After removing the line I got the below error
Unable to instantiate event handler (assembly "WorkFlowC,Version=1.0.1754.24492,Culture=Neutral, PublicKeyToken=b87bf9d85439e671", class "WorkFlowC.Engine1"), or report event for "Working docs/ProjectSite.rtf" in "Working docs". Object reference not set to an instance of an object. "Wei-Dong XU [MSFT]" wrote: [..] |
|
#4
|
|
|
|
|
Hi Manish,
After commenting that line, have you also commented the three line below? string User = strCredentials[0]; string Domain = strCredentials[1]; string Password = strCredentials[2]; They will use the returned value of the first commented line. (Credentials.GetCredentials(Convert.ToUInt32(1),"W orkflowC",ref strCredentials);) Expect for your reply! Best Regards, Wei-Dong Xu Microsoft Product Support Services Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
|
#5
|
|
|
|
|
Thank Wei, It did work.
But I am unable to move the custom property (using hashtable) from document library to list. Manish "Wei-Dong XU [MSFT]" wrote: [..] |
|
#6
|
|
|
|
|
Hi Manish,
Document library, in fact, is vastly different to other lists when we want to perform the copy operation. In other list, we can only pass the list value from one to another list's items. Since Document library is based on files, it is essentially one file copy operation. The SDK page below introduces the sample code for you: CopyTo(String, Boolean) Method http://msdn.microsoft.com/library/de...us/spptsdk/htm l/tsmSPFileCopyTo2.asp So I think there is no need to use the hashtable for the copying. Please feel free to let me know if you have any question. Best Regards, Wei-Dong Xu Microsoft Product Support Services Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. |
|
|
| Similar Threads | |
| Application error event Id 1000 This strikes me as a bit wierd, I keep getting this recurring error on customers' machine's. It happens whe closing outlook with Word as the email editor, but does not affect... |
|
| Windows Service application Occurs Application Error Event ID 1000 Hi, My program is a windows service program, it is used C# to develop. But sometime it would occurs Application Error Message, the Event ID is 1000 and the category is 100.... |
|
| System event id 1000 application error I have been having problems starting my card reader in my hp1215 printer for some time. This is the error I receive. I have tried updating my printer drivers from HP, and... |
|
| Handling Document Library Event I ran the EventSink assembly for event logging messages in case changes ocurr in document library. link:... |
|
| How to make event handling in Document Library Dear All, I am newbie on Sharepoint Server V2 development. My task is to register an event handler on document library on vs.net enviorenment.But does anybody can show me a... |
|
|
All times are GMT. The time now is 11:16 AM. | Privacy Policy
|