Cicode Programming Reference > Cicode Function Categories > .Net Functions > DllClassCreate

DllClassCreate

Use this function to instantiate a new .Net object by specifying the path, class and arguments required for the matching constructor of the class.

This function is a blocking function. It blocks the calling Cicode task until the operation is complete.

Note: If your .Net assembly was compiled for 32 bit, it will not be supported on an alarm server operating in Extended Memory mode. To allow this to work, you will need to recompile the assembly to target "Any CPU" or "x64".

Syntax

OBJECT DllClassCreate(STRING sPath, STRING sClass [, vParameters Args])

sPath:

The full path string.

sClass:

The class of the object.

Args:

Args for the constructor.

Return Value

.Net object if successful, otherwise an error code is returned.

Related Functions

DllClassDispose, DllClassIsValid DllClassCallMethod, DllClassSetProperty, DllClassGetProperty

Example

FUNCTION RunDllProxyTest()
	STRING sPath = "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.dll";
	OBJECT hMailMessageProxy;
	OBJECT hSmtpClientProxy;
	OBJECT hMailAddressProxy;
	INT result;
	OBJECT hMailAddressCollection;

	hMailMessageProxy = DllClassCreate(sPath, "MailMessage");
	result = DllClassIsValid(hMailMessageProxy);
	hSmtpClientProxy = DllClassCreate(sPath, "SmtpClient", "mysmtpserver.schneider-electric.com");
	result = DllClassIsValid(hSmtpClientProxy);
	hMailAddressProxy = DllClassCreate(sPath, "MailAddress", "myemail@hotmail.com");
	result = DllClassIsValid(hMailAddressProxy);
	result = DllClassSetProperty(hMailMessageProxy, "From", hMailAddressProxy);

	hMailAddressCollection = DllClassGetProperty(hMailMessageProxy, "To");
	DllClassCallMethod(hMailAddressCollection, "Add", "myemail@schneider-electric.com");

	result = DllClassSetProperty(hMailMessageProxy, "Subject", "Test");
	result = DllClassSetProperty(hMailMessageProxy, "Body", "Hello!");

	DllClassCallMethod(hSmtpClientProxy, "Send", hMailMessageProxy);

	result = DllClassDispose(hMailAddressProxy);
	result = DllClassDispose(hSmtpClientProxy);
	result = DllClassDispose(hMailMessageProxy);
END
				

See Also

.Net Functions

Published June 2018