How do you reference System.Xml from a C# Template?

Any template questions or comments or suggestions

How do you reference System.Xml from a C# Template?

Postby ormico on Fri Oct 26, 2007 5:22 pm

I have tried

Code: Select all
<%#REFERENCE C:\\\\WINDOWS\\\\Microsoft.NET\\\\Framework\\\\v2.0.50727\\\\System.Xml.dll%><%
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Xml;

and

Code: Select all
<%#REFERENCE System.Xml.dll%><%
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Xml;

but both give me the following error

OS Version: Microsoft Windows NT 5.1.2600 Service Pack 2
EXE Version: 1.3.0.0
-----------------------------------------------------------------
Date: 10/26/2007 1:13:23 PM
TemplateFileName: C:\\Program Files\\MyGeneration\\Templates\\ormico\\Data Access Layer (C#, SQL Server).zeus
TemplateIdentifier: 47862b8e-aa99-41c1-99d8-d0bc72d261a8
Class: Template
IsWarning: False
IsRuntime: True
IsTemplateCodeSegment: True
ErrorType: NullReferenceException
SourceLine: EngineExecuteCode
LineNumber: 0
ColumnNumber: 0
Message: Object reference not set to an instance of an object.
Detail: at Zeus.DotNetScript.DotNetScriptExecutioner.EngineExecuteCode(IZeusCodeSegment segment, IZeusContext context)
at Zeus.ZeusExecutioner.ExecuteCode(IZeusExecutionHelper helper, IZeusTemplate template, IZeusContext context, ArrayList templateGroupIds)


I've tried this on the current release version of MyGeneration and the current Beta. I've tried it on Windows Vista Ultimate 32bit and on Windows XP Pro 32bit. I get the same error each time, so I think I must be doing something wrong.
ormico
Corporal
 
Posts: 21
Joined: Mon Mar 26, 2007 2:16 pm

Postby ormico on Sun Oct 28, 2007 2:11 am

I figured out my problem with the Reference. Turns out I made a runtime error in the code I added that needed that reference. I wrote a function that was supposed to return an object or a null but I forgot to check the value returned for null before using it. I was just confused because the error pops up immediatly so I thought it happened when the template loaded, and the call stack on the error made me think it happened in the method that loaded the script, but it was actually in the script.

I changed my code to

Code: Select all
<%#REFERENCE System.Xml.dll%><%#NAMESPACE System.IO,System.Xml,System.Globalization,System.Text,System.Text.RegularExpressions,Dnp.Utils,System.Collections,System.Collections.Generic %><%
public class GeneratedTemplate : DotNetScriptTemplate
{
ormico
Corporal
 
Posts: 21
Joined: Mon Mar 26, 2007 2:16 pm


Return to General Template Questions/Comments

Who is online

Users browsing this forum: No registered users and 1 guest

cron