Hi,
I have modified my test function with appdomain, and I am calling the function inside the the new appdomain. In the new appdomain i have specified the ConfigurationFile path, eventhough it is looking into the different path, I dont understand why. I am getting the error message as
Exception Message:
"Failed to load configuration file: Config
coherence.xml"
StackTrace
" at Tangosol.Net.CacheFactory.LoadConfiguration() in c:\\dev\\release.net\\coherence-net-v3.3\\src\\Coherence\\Net
CacheFactory.cs:line 262\r\n at Tangosol.Net.CacheFactory.get_Config() in c:\\dev\\release.net\\coherence-net-v3.3\\src\\Coherence\\Net
CacheFactory.cs:line 80\r\n at Tangosol.Net.CacheFactory.get_ConfigurableCacheFactoryConfig() in c:\\dev\\release.net\\coherence-net-v3.3\\src\\Coherence\\Net
CacheFactory.cs:line 187\r\n at Tangosol.Net.CacheFactory.get_ConfigurableCacheFactory() in c:\\dev\\release.net\\coherence-net-v3.3\\src\\Coherence\\Net
CacheFactory.cs:line 128\r\n at Tangosol.Net.CacheFactory.GetCache(String name) in c:\\dev\\release.net\\coherence-net-v3.3\\src\\Coherence\\Net
CacheFactory.cs:line 428\r\n at FrontOffice3DGDLL.TestClass.Initilise() in C:\\Satish\\Projects\\CVSCode\\FO3DG_Addin
TestClass.cs:line 21"
InnerException:
"file [H:\\DATA\\Config
coherence.xml] cannot be resolved to local file path - resource does not use 'file:' protocol."
InnerException StackTrace:
" at Tangosol.IO.Resources.FileResource.get_InputStream() in c:\\dev\\release.net\\coherence-net-v3.3\\src\\Coherence\\IO\\Resources
FileResource.cs:line 115\r\n at Tangosol.Util.XmlUtils.LoadXml(String path) in c:\\dev\\release.net\\coherence-net-v3.3\\src\\Coherence\\Util
XmlUtils.cs:line 799\r\n at Tangosol.Net.CacheFactory.LoadConfiguration() in c:\\dev\\release.net\\coherence-net-v3.3\\src\\Coherence\\Net
CacheFactory.cs:line 258"
Please find the below code for your referecne:
public object testTangosol()
{
try
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(delegate(object sender, ResolveEventArgs args)
{
string requestedName = args.Name;
foreach (Assembly loadedAssembly in AppDomain.CurrentDomain.GetAssemblies())
{
string foundName = loadedAssembly.FullName;
if (requestedName.Equals(foundName))
{
return loadedAssembly;
}
}
return null;
});
string dllLoaction = GetType().Assembly.Location;
string dllFolder = dllLoaction.Substring(0, dllLoaction.LastIndexOf(@"\"));
AppDomainSetup domainInfo = new AppDomainSetup();
domainInfo.ApplicationBase = dllFolder;
domainInfo.ConfigurationFile = "FrontOffice3DGDLL.dll.config";
AppDomain newDomain = AppDomain.CreateDomain("FrontOffice3DGDLL", null, domainInfo);
object objTemp = newDomain.InitializeLifetimeService();
TestClass tangosol = (TestClass)newDomain.CreateInstanceAndUnwrap(Path.GetFileNameWithoutExtension(GetType().Assembly.Location), typeof(TestClass).FullName);
tangosol.Initilise();
return 0;
}
catch (Exception ex)
{
return "Error: " + ex.Message;
}
}
and the TestClass is
class TestClass : MarshalByRefObject
{
public void Initilise()
{
try
{
Tangosol.Net.INamedCache cache = Tangosol.Net.CacheFactory.GetCache("TRADECAPTURE");
System.Windows.Forms.MessageBox.Show(cache.Count.ToString());
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message.ToString());
}
}
}