Click here to Skip to main content
15,922,894 members
Home / Discussions / C#
   

C#

 
GeneralIIS server Pin
ppp00128-Oct-04 6:41
ppp00128-Oct-04 6:41 
GeneralRe: IIS server Pin
Alex Korchemniy28-Oct-04 9:59
Alex Korchemniy28-Oct-04 9:59 
GeneralRe: IIS server Pin
Heath Stewart28-Oct-04 15:22
protectorHeath Stewart28-Oct-04 15:22 
GeneralAVI to WMV Pin
ee9903528-Oct-04 6:00
ee9903528-Oct-04 6:00 
GeneralRe: AVI to WMV Pin
Heath Stewart28-Oct-04 15:10
protectorHeath Stewart28-Oct-04 15:10 
GeneralXslTransform object protection level problem Pin
kroakdammit28-Oct-04 5:48
kroakdammit28-Oct-04 5:48 
GeneralRe: XslTransform object protection level problem Pin
Heath Stewart28-Oct-04 15:05
protectorHeath Stewart28-Oct-04 15:05 
GeneralRe: XslTransform object protection level problem Pin
kroakdammit28-Oct-04 23:24
kroakdammit28-Oct-04 23:24 
Thanks for the reply.

With regards to the ConfigurationSettings line of code, this was purely for a test application that I had direct control over so I hadn't put any validation in the code at the time.

Within my Class file I defined two string properties that will give a path to an import and export XSLT file. When these properties are set I will check for a valid path etc ... I've just illustrated the null case below.

<br />
public string XslImportTransform<br />
{<br />
 getreturn m_XslImportTransform; }<br />
 set {  m_XslImportTransform = value;<br />
        RuleBroken("** Error: Invalid XSLT file.",m_XslExportTransform == null); }<br />
}<br />


When I tried to create an XslTransform object in a private method of the class, using the string property to Load() the XslTransform, I was encountering the protection level error (NB: It was not the Load() method that was causing the problem but the instantiation call XmlTransform myXsl = new Transform(); ). I couldn't understand why this was happening because I was creating the XslTransform as a local variable to the method (the name did not clash with any reserved words, public or private members).

<br />
public void WriteFFWImportFile(string strFileToLoad, string strFileToSave)<br />
{<br />
   try<br />
    {<br />
       //create a transform object to apply load the xslt conversion template<br />
       XslTransform myXsl = new XslTransform(this.m_XslImportTransform);<br />
       myXsl.Load(this.m_XslImportTransform);<br />
    <br />
       //add the file imported from a parameter of the xslt<br />
       XsltArgumentList myArgs = new XsltArgumentList();<br />
       myArgs.AddParam("ParsolImport","",strFileToLoad);<br />
	<br />
       //create streams to allow us to write the file<br />
       Stream  fs	        = new FileStream(strFileToSave,FileMode.Create);<br />
       XmlWriter writer	= new XmlTextWriter(fs,System.Text.Encoding.Unicode);<br />
			<br />
       //load the import file<br />
       XmlDocument myXml = new XmlDocument();<br />
       myXml.Load(strFileToLoad);<br />
       myXsl.Transform(myXml,myArgs,writer,null);<br />
	<br />
       //dispose of in memory objects<br />
       writer.Close();<br />
       fs.Close();<br />
   }<br />
  catch(Exception ex)<br />
   {<br />
       //Log exception with Microsoft.ApplicationBlocks.ExceptionManager<br />
       ExceptionManager.Publish(ex);<br />
   }<br />
}<br />


Is it simply a case that all XslTransform objects have to be exposed as public when used in a Class? If so why is that the case?

I have changed the class so I can set a transform object as a public property and everything works fine, although I only wanted to load the transform when a specific method is called.

Once again thanks for all your help. Smile | :)

Paul Griffiths
.NET Developer
GeneralRe: XslTransform object protection level problem Pin
kroakdammit28-Oct-04 23:33
kroakdammit28-Oct-04 23:33 
GeneralCopy a piece of an Image Pin
delemur28-Oct-04 5:20
delemur28-Oct-04 5:20 
GeneralRe: Copy a piece of an Image Pin
Christian Graus28-Oct-04 9:36
protectorChristian Graus28-Oct-04 9:36 
GeneralRe: Copy a piece of an Image Pin
Alex Korchemniy28-Oct-04 9:56
Alex Korchemniy28-Oct-04 9:56 
QuestionHow to do this in C#? Pin
momer28-Oct-04 5:02
momer28-Oct-04 5:02 
AnswerRe: How to do this in C#? Pin
Christian Graus28-Oct-04 9:39
protectorChristian Graus28-Oct-04 9:39 
GeneralRe: How to do this in C#? Pin
Mike Dimmick28-Oct-04 10:47
Mike Dimmick28-Oct-04 10:47 
GeneralRe: How to do this in C#? Pin
momer28-Oct-04 14:57
momer28-Oct-04 14:57 
GeneralRe: How to do this in C#? Pin
Christian Graus28-Oct-04 15:01
protectorChristian Graus28-Oct-04 15:01 
GeneralRe: adding parameter to eventhandler Pin
sreejith ss nair28-Oct-04 2:18
sreejith ss nair28-Oct-04 2:18 
GeneralRe: adding parameter to eventhandler Pin
Stefan Troschuetz28-Oct-04 2:44
Stefan Troschuetz28-Oct-04 2:44 
GeneralRe: adding parameter to eventhandler Pin
Nick Parker28-Oct-04 3:35
protectorNick Parker28-Oct-04 3:35 
GeneralRe: adding parameter to eventhandler Pin
Member 147654828-Oct-04 3:51
Member 147654828-Oct-04 3:51 
GeneralRe: adding parameter to eventhandler Pin
Nick Parker28-Oct-04 5:01
protectorNick Parker28-Oct-04 5:01 
GeneralRe: adding parameter to eventhandler Pin
Anonymous28-Oct-04 6:08
Anonymous28-Oct-04 6:08 
GeneralRe: adding parameter to eventhandler Pin
Heath Stewart28-Oct-04 14:52
protectorHeath Stewart28-Oct-04 14:52 
Generaladding parameter to eventhandler Pin
Member 147654828-Oct-04 1:57
Member 147654828-Oct-04 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.