Quantcast
Viewing all articles
Browse latest Browse all 73760

Error writing streamfile AX 2009

Hello,

when I run this method from a runbasebatch class I get the following exception error in the calling new() method, if I run from a Job I get not errors.

Object 'CLRObject' could not be created

Any idea?

 

from runbasebatch: LSP_FileManager::writeFileStream(fileName, content);   (this class has calledfrom property)

server static void writeFileStream(str _fileName, str _content)
 {
    System.IO.StreamWriter sw;
    InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
    ;

    perm.assert();

    sw = new System.IO.StreamWriter(_fileName, false);

    sw.Write(_content);
    sw.Flush();
    sw.Close();
    sw.Dispose();

    CodeAccessPermission::revertAssert();
}

where _filename is '\\se-srv3\mydir\filetest.txt'

 

and the job:

server static void job15_writefilestream()
 {
    System.IO.StreamWriter sw;
    InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
    str _fileName = @'\\Se-srv3\mydir\filetest.txt';
    str _content ="A";
    ;
    perm.assert();

    sw = new System.IO.StreamWriter(_fileName, false);

    sw.Write(_content);
    sw.Flush();
    sw.Close();
    sw.Dispose();

    CodeAccessPermission::revertAssert();
}


Viewing all articles
Browse latest Browse all 73760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>