Skip to main content
Hi all,

I worte a customized Project Template which created an instance of Code Modules, and in the project property added the reference that will be used in the customized code module. I got an error when compile in K2 studio:

====================
Compile ProjectName...
Compile Error: Imports Line 0: Metadata file 'namespace.dll' could not be found
====================

I placed the assembly (the required reference) in the K2 bin directory before I compiled. Here is the code:

K2ProjectObj.References.Add("namespace.dll","",false);


But if I changed the statement to:

K2ProjectObj.References.Add(@"C:program filesk2in
amespace.dll","",false);

then it compiles successfully, but when I exported to the k2 server, got an error:

====================
Exporting to server...
The given path's format is not supported.
====================
It seems like the K2 server doesn't like to full path format, but if I don't specify the full path, then i get compile error, if I do, it won't get passed the K2 server.

Any suggestion, thanks a lot.

Patrick
Hi,

The 'References.Add' method adds the assembly as a reference to the K2 solution, but it DOES NOT physically copy the file to the solution's Bin directory. To do this, you will need something like this:


Public Sub AddNonGACReference(ByVal oK2Project As K2Studio.Project, ByVal sRefName As String, ByVal sRefFullName As String)
Dim SrcFile As String = sRefFullName
Dim DstFile As String = oK2Project.References.ReferenceFolder & "" & sRefName

If System.IO.File.Exists(SrcFile) And Not System.IO.File.Exists(DstFile) Then
Try
System.IO.File.Copy(SrcFile, DstFile)
oK2Project.References.Add(sRefName, sRefFullName, False)
Catch ex As Exception
'Ignore Error - reference would not be added and file will not be copied.
End Try
End If

End Sub

And then call the code with something like:
AddNonGACReference(MyK2Project, "Namespace.dll", "C:Program FilesK2.net 2003BinNamespace.dll")

Hope this helps,
Ockert
Hi Ockert,

Thanks for your reply. It helps!!!

Patrick
Hi Ockert, Patrick,

Just a couple of questions on this solution:

1. Is there a registry entry that indicates where the K2.net 2003 bin directory is? If so, then how do I find it?

2. Is this not "just" a problem during development? I would suspect that you would provide a setup program that would then copy all required external assemblies with the solution and then distribute these to the correct locations.

Obviously, when I have the answer to 1. above then the setup is trivial.

Regards,
Graham
Hi Graham,

Sorry for the delayed reply...

1. Is there a registry entry that indicates where the K2.net 2003 bin directory is? If so, then how do I find it?
Yes, have a look at: HKEY_LOCAL_MACHINESOFTWARESourceCodeK2.net 2003Install Settings
The question is: Why would you need that?

2. Is this not "just" a problem during development? I would suspect that you would provide a setup program that would then copy all required external assemblies with the solution and then distribute these to the correct locations.
Difficult to answer... If you generate process definitions dynamically by using the K2Studio object model, I assume the reason for it would be to make it easier for business users to create their own processes and export it to the K2.net Server.
I suppose it depends on the flexibility to build into your app which will determine whether this is a design-time problem only or a run-time problem also.
Generally speaking though, I would agree with your statement above.

Regards,
Ockert

Ockert,

I need these details if someone has installed in a different location than the c drive. In my install program I can pick up the registry value and use that to install my components. Thats all.

Graham
Ockert,

I need these details if someone has installed in a different location than the c drive. In my install program I can pick up the registry value and use that to install my components. Thats all.

Graham

Reply