470,647 Members | 1,313 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

Problems using FileStream in a seperate AppDomain

Hey,

I've created a very simple test app to try and fix a problem I'm
having. Basically I'm trying to log to a text file from a class in a
seperate app domain that I've created. When I first create the
AppDomain I'm able to log. However, I have the requirement that I'll
have to tear down the AppDomain and then load it back up again. When I
do this I no longer get any logging.
Note that the first thing I thought of is that the file was somehow not

being release, but I've modified the code below to create with a
different filename each time the AppDomain is loaded with no success.
Any help would be appreciated!
***** Text Logger *****
using System;
using System.IO;
using System.Text;
namespace prairieFyre.IQRealtimeClient
{
public class TestLogger : MarshalByRefObject
{
StreamWriter m_fileWriter;
public TestLogger()
{
FileStream stream = new FileStream("TestLogger.txt",
FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
m_fileWriter = new StreamWriter(stream);
}
public void WriteText()
{
m_fileWriter.WriteLine("THIS IS MY TEST!");
m_fileWriter.Flush();
}
}

}
******* Test App *******

(this loads the AppDomain)
m_realtimeAppDomain = AppDomain.CreateDomain("Realtime AppDomain");
TestLogger testLogger =
(TestLogger)m_realtimeAppDomain.CreateInstanceAndU nwrap("RealtimeClient",

"prairieFyre.IQRealtimeClient.TestLogger");
testLogger.WriteText();
testLogger.WriteText();
(This is how I unload the AppDomain)
AppDomain.Unload(m_realtimeAppDomain);
m_realtimeClient = null;

Aug 18 '06 #1
1 1504
Please post a 'complete' sample that illustrates the issue, not just a
couple of code snippets.

Willy.

"Dan Dorey" <da*******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
| Hey,
|
| I've created a very simple test app to try and fix a problem I'm
| having. Basically I'm trying to log to a text file from a class in a
| seperate app domain that I've created. When I first create the
| AppDomain I'm able to log. However, I have the requirement that I'll
| have to tear down the AppDomain and then load it back up again. When I
| do this I no longer get any logging.
|
|
| Note that the first thing I thought of is that the file was somehow not
|
| being release, but I've modified the code below to create with a
| different filename each time the AppDomain is loaded with no success.
|
|
| Any help would be appreciated!
|
|
| ***** Text Logger *****
|
|
| using System;
| using System.IO;
| using System.Text;
|
|
| namespace prairieFyre.IQRealtimeClient
| {
| public class TestLogger : MarshalByRefObject
| {
| StreamWriter m_fileWriter;
|
|
| public TestLogger()
| {
| FileStream stream = new FileStream("TestLogger.txt",
| FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
| m_fileWriter = new StreamWriter(stream);
|
|
| }
|
|
| public void WriteText()
| {
| m_fileWriter.WriteLine("THIS IS MY TEST!");
| m_fileWriter.Flush();
| }
| }
|
|
|
| }
|
|
| ******* Test App *******
|
| (this loads the AppDomain)
| m_realtimeAppDomain = AppDomain.CreateDomain("Realtime AppDomain");
| TestLogger testLogger =
| (TestLogger)m_realtimeAppDomain.CreateInstanceAndU nwrap("RealtimeClient",
|
| "prairieFyre.IQRealtimeClient.TestLogger");
|
|
| testLogger.WriteText();
| testLogger.WriteText();
|
|
| (This is how I unload the AppDomain)
| AppDomain.Unload(m_realtimeAppDomain);
| m_realtimeClient = null;
|
Aug 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Shane Mergy | last post: by
9 posts views Thread by Lawrence Oluyede | last post: by
1 post views Thread by Andreas HŚkansson | last post: by
3 posts views Thread by CSH | last post: by
1 post views Thread by Kiana Toufighi | last post: by
reply views Thread by neoret | last post: by
reply views Thread by neoret | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.