PROBLEMA AO CHAMAR FUNCAO DA DLL
[txt-color=#007100]boa noite, estou tendo um problema em chamar essa função da dll aqui [/txt-color]
[txt-color=#e80000]e aqui eu chamo ela porem retorna sempre o erro da imagem a baixo[/txt-color]
alguem pode me dar uma luz
chamando assim
e utilizando o using da dll
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace Wilcom.Engines.WDCEmbEngine
{
public static class WDCEmbEngine
{
private static object syncLock;
private static DllInterface dllInterface;
public static string EngineDll
{
get
{
string text = ConfigurationManager.get_AppSettings()["EngineDLL"];
if (Path.IsPathRooted(text))
{
return text;
}
return Path.Combine(Environment.CurrentDirectory, text);
}
}
public static string EngineVersion
{
get
{
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(EngineDll);
return " (" + Path.GetFullPath(EngineDll) + ", ver " + versionInfo.ProductMajorPart + "." + versionInfo.ProductMinorPart + "." + versionInfo.ProductBuildPart + "." + versionInfo.ProductPrivatePart + ", " + File.GetLastWriteTime(EngineDll).ToString() + ")";
}
}
static WDCEmbEngine()
{
syncLock = new object();
string directoryName = Path.GetDirectoryName(EngineDll);
string environmentVariable = Environment.GetEnvironmentVariable("PATH");
string value = directoryName + ";" + environmentVariable;
Environment.SetEnvironmentVariable("PATH", value);
dllInterface = CreateDLLInterface();
}
private static DllInterface CreateDLLInterface()
{
string fileName = Path.GetFileName(EngineDll);
Type[] types = typeof(DllInterface).Assembly.GetTypes();
foreach (Type type in types)
{
if (type.IsSubclassOf(typeof(DllInterface)) && !type.IsAbstract)
{
DllInterface dllInterface = type.GetConstructor(Type.EmptyTypes).Invoke(null) as DllInterface;
if (dllInterface.GetDllName().Equals(fileName, StringComparison.OrdinalIgnoreCase))
{
return dllInterface;
}
}
}
throw new Exception("Unsupported engine dll name: " + fileName);
}
public static bool SupportsCreateDesign()
{
return dllInterface.SupportsCreateDesign();
}
public static XmlEngineInfo GetEngineInfo()
{
object[] array = new object[1];
CallEngineAPI("WDCEmbEngine_GetEngineInfo", array);
XmlEngineInfo xmlEngineInfo = StringXmlSerializer.Deserialize<XmlEngineInfo>(array[0] as string);
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(EngineDll);
xmlEngineInfo.engine_info.engine_version = new engine_version
{
major = versionInfo.ProductMajorPart,
minor = versionInfo.ProductMinorPart,
build = versionInfo.ProductBuildPart,
privat = versionInfo.ProductPrivatePart
};
return xmlEngineInfo;
}
public static XmlDesignInfo GetDesignInfo(string designFilename)
{
object[] array = new object[2] { designFilename, null };
CallEngineAPI("WDCEmbEngine_GetDesignInfo", array);
return StringXmlSerializer.Deserialize<XmlDesignInfo>(array[1] as string);
}
public static XmlDesignInfo GetDesignInfoAndTrueview(string designFilename, int dpi)
{
object[] array = new object[3] { designFilename, null, dpi };
CallEngineAPI("WDCEmbEngine_GetDesignInfoAndTrueview", array);
return StringXmlSerializer.Deserialize<XmlDesignInfo>(array[1] as string);
}
public static XmlDesignInfo GetDesignInfoAndThumbnail(string designFilename)
{
object[] array = new object[2] { designFilename, null };
CallEngineAPI("WDCEmbEngine_GetDesignInfoAndThumbnail", array);
return StringXmlSerializer.Deserialize<XmlDesignInfo>(array[1] as string);
}
public static XmlDesignInfo GenerateTrueview(XmlEngineDocument xmlEngineDocument)
{
string text = StringXmlSerializer.Serialize(xmlEngineDocument);
object[] array = new object[2] { text, null };
CallEngineAPI("WDCEmbEngine_GenerateTrueview", array);
return StringXmlSerializer.Deserialize<XmlDesignInfo>(array[1] as string);
}
public static XmlDesignInfo GenerateDesign(XmlEngineDocument xmlEngineDocument)
{
string text = StringXmlSerializer.Serialize(xmlEngineDocument);
object[] array = new object[2] { text, null };
CallEngineAPI("WDCEmbEngine_GenerateDesign", array);
return StringXmlSerializer.Deserialize<XmlDesignInfo>(array[1] as string);
}
public static XmlDesignInfo GenerateLetteringPreview(XmlEngineDocument xmlEngineDocument)
{
string text = StringXmlSerializer.Serialize(xmlEngineDocument);
object[] array = new object[2] { text, null };
CallEngineAPI("WDCEmbEngine_GenerateLetteringPreview", array);
return StringXmlSerializer.Deserialize<XmlDesignInfo>(array[1] as string);
}
private static void CallEngineAPI(string methodName, object[] methodParams)
{
lock (syncLock)
{
uint num = 0u;
MethodInfo method = dllInterface.GetType().GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic);
if (method == null)
{
throw new Exception("Method " + methodName + " cannot be found in " + dllInterface.GetDllName());
}
num = (uint)method.Invoke(null, methodParams);
if (num != 0)
{
throw new Exception("Call to " + methodName + " failed.
Return code: " + ErrorCodes.GetErrorCode(num));
}
}
}
}
}
[txt-color=#e80000]e aqui eu chamo ela porem retorna sempre o erro da imagem a baixo[/txt-color]
alguem pode me dar uma luz
chamando assim
e utilizando o using da dll
try
{
var temp = WDCEmbEngine.GetDesignInfo(@"D:\backup dados\clientes este\SOLAR.EMB");
}
catch (Exception exception1)
{
Console.WriteLine(exception1.ToString());
}
Faça seu login para responder