Community forum

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


ErikC
  •  ErikC
  • Paid support Topic Starter
2014-06-12T07:52:45Z
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:

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
Uses Visualcron since 2006.
Sponsor
Forum information
ErikC
  •  ErikC
  • Paid support Topic Starter
2014-06-12T08:23:16Z
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.
Support
2014-06-15T08:31:03Z
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.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
ErikC
  •  ErikC
  • Paid support Topic Starter
2014-06-16T06:16:39Z
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.
Support
2014-06-16T07:41:53Z
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.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
ErikC
  •  ErikC
  • Paid support Topic Starter
2014-06-16T08:50:23Z
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.
Support
2014-07-19T18:12:16Z
Hi Erik,

we have made some changes in the latest beta to avoid conflicts with using the .NET Code Task to connect locally. Please test it here:

http://www.visualcron.co...sts&t=4259#post18862 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top