Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Workflow for SharePoint and signed dlls

Status
Not open for further replies.

AndyH1

Programmer
Jan 11, 2004
350
GB
I wonder if anyone can help. Ive been asked to develop a custom workflow for our Sharepoint site. Ive never done this before so have tried an example ne that was given at


The problem is that the tutorial is very much incomplete with some code missing and I do not understand a lot about the signing and registering of the dll. The code seems to compile and the action apears in Sharepoint designer but then I get an error when I attempt to use it:

(18, 33) The type name 'EventLogger' does not exist in the type 'MyCustomActivity.MyCustomActivity')

First, I managed, I thought, to add the missing code from the example

I installed the Visual Studio 2005 Extensions for the .NET Framework 3.0 (Windows Workflow Foundation) in my Visual Studio and used the Worflow Activity Library as my starting point.

The following is the code in the MyCustomActivity.xoml.cs I created:

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

namespace MyCustomActivity
{
public partial class EventLogger: Activity
{
#region Activity Designer generated code


[System.Diagnostics.DebuggerNonUserCode]
private void InitializeComponent()
{
this.Name = "EventLogger";
}

#endregion

public EventLogger()
{
InitializeComponent();
}

public static DependencyProperty MessageProperty
= System.Workflow.ComponentModel.DependencyProperty.Register(
"Message", typeof(string), typeof(EventLogger));
[Category("MyCustomActivity"), Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Message
{
get
{
return ((string)(base.GetValue(EventLogger.MessageProperty)));
}
set
{
base.SetValue(EventLogger.MessageProperty, value);
}
}

protected override ActivityExecutionStatus
Execute(ActivityExecutionContext executionContext)
{
using (System.Diagnostics.EventLog log = new System.Diagnostics.EventLog("MyCustomActivity"))
{
try
{
log.Source = "EventLogger Activity";
log.WriteEntry(this.Message, System.Diagnostics.EventLogEntryType.Information);
}
catch
{
}
}
return ActivityExecutionStatus.Closed;
}

}
}

I signed the assembly and generated an MyCustomActivity.snk file and successfully compiled the code to produce a file MyCustomActivity.dll.

I copied the file to the GAC

Using .net refractor on the dll I got

// Assembly MyCustomActivity, Version 1.0.0.0
Location: C:\workflowassembly\MyCustomActivity.dll
Name: MyCustomActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=dbcd38cb75eee5c1
Type: Library

which I used to register the file in the Sharepoint web.config

<authorizedType Assembly="MyCustomActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=dbcd38cb75eee5c1" Namespace="MyCustomActivity" TypeName="*" Authorized="True" />

and created the action file and put it in the Sharepoint Designer

<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
<Actions Sequential="then" Parallel="and">
<Action Name="Write Message To Event Log" ClassName="EventLogger" Assembly="MyCustomActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=dbcd38cb75eee5c1" AppliesTo="all" Category="MyCustomActivities">
<RuleDesigner Sentence="Write '%1' to the event log">
<FieldBind Field="Message" DesignerType="TextArea" Id="1"/>
</RuleDesigner>
<Parameters>
<Parameter Name="Message" Type="System.String, mscorlib" Direction="In"/>
</Parameters>
</Action>
</Actions>
</WorkflowInfo>

I went into Sharepoint Designer and did File > New > Workflow and can see and chose the Write Message to Log' under actions and it comes up correctly and can have the message field filled in and I also added a condition

HOWEVER,when I click Finish I get 'Errors were found compiling the worflow', and if I click advanced on the error I get

(18, 33) The type name 'EventLogger' does not exist in the type 'MyCustomActivity.MyCustomActivity')

and it cannot be run.

I have not used signed files before and wonder about the .snk file. I used gacutil.exe /i to install the dll do I need to do something with the snk file? Also I'm not sure if I filled in the web.config and action file Namespace, ClassName and Assembly field correctly, as the tutorial changes the names completely and I'm not sure what they should be

Hope someone can help point me to a solution to what Ive done wrong

Thanks in advance
AndyH1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top