Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Duncan
2009-03-02T17:47:18Z
Hi,

I've run into an interesting problem and wonder if you've got an answer. I've got a .NET assembly that I need to load through reflection and this assembly refers to the VisualCron API. Which all works fine. However, when it is loaded through reflection it cannot connect to the server using the connection type VisualCronAPI.Connection.ConnectionT.Local

I can connect to the local server using a remote connection without any problems. So a work around is available, but as the Local connection is faster I would ideally like to use that where possible.

This problem is easy to replicate as you can just load the API dll using reflection, or you can put the below into a VB.NET console app changing where necessary.

Thanks in advance for any help you can offer

Duncan

Sub Main()
Try

Dim _APIAssembly As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom("C:\Program Files\VisualCron 4\VisualCronAPI.dll")
Dim _mod As System.Reflection.Module = _APIAssembly.GetModule("VisualCronAPI.dll")

Dim _VCClient As Object = _APIAssembly.CreateInstance("VisualCronAPI.Client")
Dim _VCcn As Object = _APIAssembly.CreateInstance("VisualCronAPI.Connection")
Dim _VCserver As Object

_VCcn.TimeOut = 10

_VCcn.ConnectionType = 0

'_VCcn.ConnectionType = 1
'_VCcn.UserName = "admin"
'_VCcn.PassWord = ""
'_VCcn.Port = 16444
'_VCcn.Address = "Localhost"

_VCserver = _VCClient.Connect(_VCcn, True)

Console.WriteLine("VisualCron Server Connected")

Catch ex As Exception
Console.WriteLine(ex.ToString)
Finally
Console.Write("Press Any Key To Continue...")
Console.ReadKey()
End Try


End Sub
Sponsor
Forum information
Support
2009-03-02T22:25:25Z
We did some quick tests. The problem is loading the dll files. We got a little closer by moving the VisualCron.dll and VisualCronAPI.dll to the console project and set them to always output in the bin directory. Because the first problem is that it cannot find these files. But we could not find why. Is is hard to debug when using reflection but we see that first message is succesfully send, server replies but for some reason the message is not received by the client - the clients sits in a loop and wait for this message but does not receive anything.

Any special reason why you don't reference the dll directly?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2009-03-02T23:22:00Z
We got it working. We had to do the following change:

1. copy VisualCron.dll and VisualCronAPI.dll into the project and set them to be copied to output directory
2. change this line so it works with these files locally: Dim _APIAssembly As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom("VisualCronAPI.dll")

I am not an expert here but it seems to concern the working folder. Let us know if you come an closer to this. One solution if you don't want to store them in the project is to first copy these files from your source location to your local folder before starting the reflection.

Another solution would be to place your console project in the same directory as VisualCron.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Duncan
2009-03-03T10:04:57Z
Excellent that worked a treat, thank you!

The reason for reflection is that our software can be controlled by any scheduler, but we recommend VisualCron (obviously!). As that is used by most, if not all, of our clients I'm writing a plug-in to interact with VisualCron. Obviously I need to cater for the slight chance that someone might not use it and a plug-in is the best way. Therefore, it's not actually the VisualCron dlls that I'm reflecting but the plug-in, although the problem was the same.

Thanks again for your help!
Scroll to Top