我正在使用高級安裝程序8.3並試圖暗示我的應用程序的試用許可,目標操作系統是Windows 7 x32 & x64。C#內存訪問衝突Windows 7
以下代碼取自高級安裝程序提供的示例。
[DllImport("Trial.dll", EntryPoint = "ReadSettingsStr", CharSet = CharSet.Auto)]
private static extern uint InitTrial(String aKeyCode, IntPtr aHWnd);
[DllImport("Trial.dll", EntryPoint = "ReadSettingsRetStr", CharSet = CharSet.Auto)]
private static extern uint InitTrialReturn(String aKeyCode, IntPtr aHWnd);
[DllImport("Trial.dll", EntryPoint = "DisplayRegistrationStr", CharSet = CharSet.Auto)]
private static extern uint DisplayRegistration(String aKeyCode);
[DllImport("Trial.dll", EntryPoint = "GetPropertyValue", CharSet = CharSet.Auto)]
private static extern uint GetPropertyValue(String aPropName, StringBuilder aResult, ref UInt32 aResultLen);
private void registerToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
Process process = Process.GetCurrentProcess();
DisplayRegistration(kLibraryKey, process.MainWindowHandle);
}
catch(Exception ex1)
{
MessageBox.Show(ex1.ToString());
}
}
高級安裝程序中設置的類型簽名是32位unicode DEP Aware。
問題是每當我選擇註冊我得到一個訪問衝突。看來我無法使用我的應用程序中的開關來關閉DEP,因爲它是我的應用程序所需的。
有沒有人有任何想法如何繞過這一點,因爲我已經檢查了高級安裝論壇,並沒有太多類似的問題。
非常感謝
OK快速更新。
我試過所有的sig類型的組合,這是我發現的。
將類型設置爲32位Ansi(支持Win9x或更高版本)並將CharSet設置爲Ansi/Unicode或Auto result = CRASH。
將類型設置爲32位Unicode(DEP Aware),並將CharSet設置爲Unicode或Auto結果=訪問衝突。
將類型設置爲32位Unicode(DEP Aware)並將CharSet設置爲Ansi result = success。
所以,雖然它工作,但高級安裝程序顯然存在一個錯誤。
你爲什麼要打開DEP? –
@David Heffernan:顯然這是x86(ANSI)二進制文件的高級安裝程序的[要求](http://www.advancedinstaller.com/user-guide/tutorial-licensing.html)「...支持Win9x或更高版本OS並且不能用於支持DEP的應用程序「。 –
我不完全理解,但它似乎支持兩種與DEP兼容的庫類型。 –