Forum
»
Support
»
API
»
[Solved] Run .NET task with local API connection
  Rank: Paid supportJoined: 2/26/2008(UTC) Posts: 1,520  Location: Amsterdam Thanks: 114 times Was thanked: 220 time(s) in 188 post(s)
|
Hi, What am I doing wrong here... I try to connect to the VC server with a '.NET code execute' task. Here is my code: Code:public static string test()
{
Server s = null;
Client c = new Client();
Connection conn = new Connection();
conn.ConnectionType = Connection.ConnectionT.Local;
conn.UserName = "admin";
conn.PassWord = "xxx";
try
{
s = c.Connect(conn, true);
}
catch (VisualCronAPI.Client.ClientLoginFailedException ex)
{
return ex.Message;
}
if (s.Connected)
return "Connected";
else
return "Not Connected";
}
Above code returns: Object reference not set to an instance of an object. When I change the connection to Remote and add an Address and Port to the Connection, the method returns: "Not Connected". Is it possible to use the .NET code execute task to connect to the local server? When I use the code in an external c# app it works fine.. Regards, Erik Edited by moderator Saturday, July 19, 2014 8:12:34 PM(UTC)
| Reason: Not specified |
Uses Visualcron since 2006. |
|
|
|
  Rank: Paid supportJoined: 2/26/2008(UTC) Posts: 1,520  Location: Amsterdam Thanks: 114 times Was thanked: 220 time(s) in 188 post(s)
|
Hi,
One other thing though... When I 'test' the task (clicking the RUN button) the task works. When I run the task from the main window, there is an error:
Exception in Task: Could not load file or assembly 'file:///C:\WINDOWS\TEMP\avl3wt5t.dll' or one of its dependencies. The system cannot find the file specified.
When I look at the referenced dll's, the VisualCron.dll and VisualCronAPI.dll are not in the list anymore. That might be it...
Regards Erik |
Uses Visualcron since 2006. |
|
|
|
  Rank: Official supportJoined: 2/23/2008(UTC) Posts: 11,223
Thanks: 875 times Was thanked: 446 time(s) in 424 post(s)
|
Just that kind of code does not mix well with running from the Client. The reason is that we use static references to events in the Client which reacts on various connection events.
There are some problems running this server code right now. I think the best workaround is to use the Assembly Task or Execute Task. But in the future we will separate execution from main VisualCron assemblies in this .NET Code Task just as in the Assembly Tasks. |
|
|
|
|
  Rank: Paid supportJoined: 2/26/2008(UTC) Posts: 1,520  Location: Amsterdam Thanks: 114 times Was thanked: 220 time(s) in 188 post(s)
|
Hi, argghhh.. I thought this was a nice solution. Not having to rebuild my app every time when there is a new version. This way I always use the latest VC dll's... but no.. I'll make an external app in the meantime. But I think the error should be handled if we try to do this so we know it's not possible (for now  ) Regards, Erik |
Uses Visualcron since 2006. |
|
|
|
  Rank: Official supportJoined: 2/23/2008(UTC) Posts: 11,223
Thanks: 875 times Was thanked: 446 time(s) in 424 post(s)
|
Unfortunately, it is a lot at the core of the Client concerning connections, list of jobs and Tasks. We are very careful about breaking things that work right now. |
|
|
|
|
  Rank: Paid supportJoined: 2/26/2008(UTC) Posts: 1,520  Location: Amsterdam Thanks: 114 times Was thanked: 220 time(s) in 188 post(s)
|
Clear for me,
I just made an external c# application and this works fine now.
Just to let you know what I build:
My program checks if there are inactive triggers on active jobs. This result is matched with a whitelist and if there is a trigger which should not be disabled it throws an error. With the error I inform my people over here to act accordingly.
Regards, Erik |
Uses Visualcron since 2006. |
 1 user thanked ErikC for this useful post.
|
|
|
  Rank: Official supportJoined: 2/23/2008(UTC) Posts: 11,223
Thanks: 875 times Was thanked: 446 time(s) in 424 post(s)
|
|
|
|
|
|
Users browsing this topic |
Guest
|
Forum
»
Support
»
API
»
[Solved] Run .NET task with local API connection
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.