I have a small C# application that I want to call from a makefile. The
application runs correctly when run from a batch file, and when run from
a Windows XP command line.
However, when attempting to call the application from within a makefile
- the application fails.
Now - this is probably down to something I'm doing somewhere in either
the makefile or the C# app - but I'm damned if I can spot it.
I've tried running "make -n > test.bat" and running the .bat file by
hand - and it works fine. Running the C# app directly from the
makefile fails.
The C# code is fairly simple... it just uses class serialization to load
an XML file.
static public bool LoadConfigFile(string inFilename, ref InputConfigurations
outConfig)
{
XmlSerializer s = null;
TextReader r = null;
try
{
s = new XmlSerializer(typeof(InputConfigurations));
}
catch( Exception e )
{
Console.WriteLine(e.Message + "\n" + e.Source + "\n" +
e.ToString());
Console.WriteLine( "Error -- unable to create serialization for '" +
outConfig.ToString() + "'" );
return false;
}
try {
r = new StreamReader(inFilename);
outConfig = (InputConfigurations)s.Deserialize(r);
r.Close();
}
catch( Exception e )
{
Console.WriteLine(e.Message + "\n" + e.Source + "\n" +
e.ToString());
Console.WriteLine("Error -- unable to serialize input file '" +
inFilename + "'");
if (r != null)
r.Close();
return false;
}
return true;
}
Nothing particularly special - it all just works fine outside of make.
However - running the C# exe from within make results in the following
error...
Item has already been added. Key in dictionary: 'path' Key being added: 'path'
mscorlib
System.ArgumentException: Item has already been added. Key in dictionary:
'path' Key being added: 'path'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean
add)
at System.Collections.Hashtable.Add(Object key, Object value)
at System.Collections.Specialized.StringDictionary.Add(String key, String
value)
at
System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle
userToken, String cmd, Stri
ng currentDir, TempFileCollection tempFiles, String& outputName, String&
errorName, String trueCmdLine)
at System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle
userToken, String cmd, String currentDir,
TempFileCollection tempFiles, String& outputName, String& errorName, String
trueCmdLine)
at Microsoft.CSharp.CSharpCodeGenerator.Compile(CompilerParameters options,
String compilerDirectory, String compiler
Exe, String arguments, String& outputFile, Int32& nativeReturnValue, String
trueArgs)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters
options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters
options, String[] sources)
at
Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(Compiler
Parameters options, String[] sources)
at
System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters
options, String[] sources)
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns,
XmlSerializerCompilerParameters xmlParameter
s, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNames
pace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly
assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings,
Type[] types, String defaultNamespace, Strin
g location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping
xmlMapping, Type type, String defaultNamesp
ace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at genVCProj.InputConfigurations.LoadConfigFile(String inFilename,
InputConfigurations& outConfig)
Error -- unable to create serialization for 'genVCProj.InputConfigurations'
make: error: *** [genvcproj] Error -1
I'm running make 3.80, and I'm using Windows XP (SP2). I'm running from
an XP DOS Cmdline.
Is there any difference in the executable environment set up by make?
Thanks in advance.
Dave