who can help me

Mar 28, 2013 at 1:05 AM
MapWindow GIS 4.8.6 (2011/11/4)

System.InvalidCastException: 无法将类型为“System.Drawing.Icon”的对象强制转换为类型“System.Drawing.Image”。
In MapWindow.Toolbar.AddButtonNewStyle(String buttonName, Boolean IsDropDown, String toolbarName, Object picture, String buttonLabel, String After)

MapWinUtility (debug reporter) Assembly Version: 2.0.4927.50727
Operating System: Win32NT
Service Pack:
Major Version: 6
Minor Version: 1
Revision: 0

Build: 7600

Logical Drives: C:\ D:\ E:\ F:\ G:\ H:\ I:\ L:\
System Directory: C:\Windows\system32
Current Directory: C:\Users\lenovo\AppData\Roaming\MapWindow
Command Line: "D:\软件安装\MapWindow\MapWindow.exe"
Command Line Args: D:\软件安装\MapWindow\MapWindow.exe

------------Environment Variables-----------------
Path == C:\Program Files\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;D:\MATLAB7\bin\win32;C:\Program Files\Common Files\Autodesk Shared\
TEMP == C:\Users\lenovo\AppData\Local\Temp
SESSIONNAME == Console
PATHEXT == .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
USERDOMAIN == LENOVO-PC52525
PROCESSOR_ARCHITECTURE == x86
SystemDrive == C:
APPDATA == C:\Users\lenovo\AppData\Roaming
windir == C:\Windows
LOCALAPPDATA == C:\Users\lenovo\AppData\Local
configsetroot == C:\Windows\ConfigSetRoot
GDAL_DATA == D:\软件安装\MapWindow\gdal_data
TMP == C:\Users\lenovo\AppData\Local\Temp
USERPROFILE == C:\Users\lenovo
ProgramFiles == C:\Program Files
FP_NO_HOST_CHECK == NO
HOMEPATH == \Users\lenovo
COMPUTERNAME == LENOVO-PC52525
ProgramData == C:\ProgramData
USERNAME == lenovo
NUMBER_OF_PROCESSORS == 2
PROCESSOR_IDENTIFIER == x86 Family 16 Model 6 Stepping 3, AuthenticAMD
SystemRoot == C:\Windows
ComSpec == C:\Windows\system32\cmd.exe
LOGONSERVER == \LENOVO-PC52525
AMDAPPSDKROOT == C:\Program Files\AMD APP\
CommonProgramFiles == C:\Program Files\Common Files
PROCESSOR_LEVEL == 16
PROCESSOR_REVISION == 0603
PROJ_LIB == D:\软件安装\MapWindow\PROJ_NAD
BLAS_VERSION == D:\Matlab7\bin\win32\atlas_Athlon.dll
PSModulePath == C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
ALLUSERSPROFILE == C:\ProgramData
VS90COMNTOOLS == D:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\
PUBLIC == C:\Users\Public
OS == Windows_NT
HOMEDRIVE == C:

------------Performance Info (Bytes)--------------
Private Memory: 62615552
Virtual Memory: 376635392
Total CPU time: 00:00:02.5272162
Total User Mode CPU time: 00:00:02.0748133

------------Module Info:--------------------------
----Module Name: MapWindow.exe
Path:  D:\软件安装\MapWindow\MapWindow.exe
Version: 4.8.6.0
----Module Name: ntdll.dll
Path:  C:\Windows\SYSTEM32\ntdll.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: MSCOREE.DLL
Path:  C:\Windows\SYSTEM32\MSCOREE.DLL
Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
----Module Name: KERNEL32.dll
Path:  C:\Windows\system32\KERNEL32.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: KERNELBASE.dll
Path:  C:\Windows\system32\KERNELBASE.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: ADVAPI32.dll
Path:  C:\Windows\system32\ADVAPI32.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: msvcrt.dll
Path:  C:\Windows\system32\msvcrt.dll
Version: 7.0.7600.16385 (win7_rtm.090713-1255)
----Module Name: SHLWAPI.dll
Path:  C:\Windows\system32\SHLWAPI.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: GDI32.dll
Path:  C:\Windows\system32\GDI32.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: USER32.dll
Path:  C:\Windows\system32\USER32.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: LPK.dll
Path:  C:\Windows\system32\LPK.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: USP10.dll
Path:  C:\Windows\system32\USP10.dll
Version: 1.0626.7600.16385 (win7_rtm.090713-1255)
----Module Name: IMM32.DLL
Path:  C:\Windows\system32\IMM32.DLL
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: MSCTF.dll
Path:  C:\Windows\system32\MSCTF.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: mscorwks.dll
Path:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
----Module Name: MSVCR80.dll
Path:  C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_d08a205e442db5b5\MSVCR80.dll
Version: 8.00.50727.4927
----Module Name: shell32.dll
Path:  C:\Windows\system32\shell32.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: ole32.dll
Path:  C:\Windows\system32\ole32.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: profapi.dll
Path:  C:\Windows\system32\profapi.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: mscorlib.ni.dll
Path:  C:\Windows\assembly\NativeImages_v2.0.50727_32\mscorlib\8c1770d45c63cf5c462eeb945ef9aa5d\mscorlib.ni.dll
Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
----Module Name: CRYPTBASE.dll
Path:  C:\Windows\system32\CRYPTBASE.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: uxtheme.dll
Path:  C:\Windows\system32\uxtheme.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: wbshld.dll
Path:  C:\Program Files\Rising\RAV\wbshld.dll
Version: 24, 0, 1, 35
----Module Name: OLEAUT32.dll
Path:  C:\Windows\system32\OLEAUT32.dll
Version: 6.1.7600.16385
----Module Name: PSAPI.DLL
Path:  C:\Windows\system32\PSAPI.DLL
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: ntmarta.dll
Path:  C:\Windows\system32\ntmarta.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: WLDAP32.dll
Path:  C:\Windows\system32\WLDAP32.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: wbprotect.dll
Path:  C:\Program Files\Rising\RAV\wbprotect.dll
Version: 24, 0, 0, 16
----Module Name: VERSION.dll
Path:  C:\Windows\system32\VERSION.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: WININET.dll
Path:  C:\Windows\system32\WININET.dll
Version: 8.00.7600.16385 (win7_rtm.090713-1255)
----Module Name: Normaliz.dll
Path:  C:\Windows\system32\Normaliz.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: urlmon.dll
Path:  C:\Windows\system32\urlmon.dll
Version: 8.00.7600.16385 (win7_rtm.090713-1255)
----Module Name: CRYPT32.dll
Path:  C:\Windows\system32\CRYPT32.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: MSASN1.dll
Path:  C:\Windows\system32\MSASN1.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: iertutil.dll
Path:  C:\Windows\system32\iertutil.dll
Version: 8.00.7600.16385 (win7_rtm.090713-1255)
----Module Name: wintrust.dll
Path:  C:\Windows\system32\wintrust.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: imagehlp.dll
Path:  C:\Windows\system32\imagehlp.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: mscorjit.dll
Path:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll
Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
----Module Name: System.ni.dll
Path:  C:\Windows\assembly\NativeImages_v2.0.50727_32\System\5ba3bf5367fc012300c6566f20cb7f54\System.ni.dll
Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
----Module Name: System.Drawing.ni.dll
Path:  C:\Windows\assembly\NativeImages_v2.0.50727_32\System.Drawing\ead6be8b410d56b5576b10e56af2c180\System.Drawing.ni.dll
Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
----Module Name: CRYPTSP.dll
Path:  C:\Windows\system32\CRYPTSP.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: rsaenh.dll
Path:  C:\Windows\system32\rsaenh.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: RpcRtRemote.dll
Path:  C:\Windows\system32\RpcRtRemote.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: MapWinInterfaces.dll
Path:  D:\软件安装\MapWindow\MapWinInterfaces.dll
Version: 4.8.6.0
----Module Name: MapWindow.Controls.dll
Path:  D:\软件安装\MapWindow\MapWindow.Controls.dll
Version: 4.8.6.0
----Module Name: System.Xml.ni.dll
Path:  C:\Windows\assembly\NativeImages_v2.0.50727_32\System.Xml\5dd9f783008543df3e642ff1e99de4e8\System.Xml.ni.dll
Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
----Module Name: Interop.MapWinGIS.dll
Path:  D:\软件安装\MapWindow\Interop.MapWinGIS.dll
Version: 4.8.0.0
----Module Name: Microsoft.VisualBasic.ni.dll
Path:  C:\Windows\assembly\NativeImages_v2.0.50727_32\Microsoft.VisualBas#\965b1fa2decab0efc0c837ab7252bba1\Microsoft.VisualBasic.ni.dll
Version: 8.0.50727.4927 (NetFXspW7.050727-4900)
----Module Name: CLBCatQ.DLL
Path:  C:\Windows\system32\CLBCatQ.DLL
Version: 2001.12.8530.16385 (win7_rtm.090713-1255)
----Module Name: MapWinGIS.ocx
Path:  D:\软件安装\MapWindow\MapWinGIS.ocx
Version: 4.8.6.0
----Module Name: gdiplus.dll
Path:  C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7600.16385_none_72fc7cbf861225ca\gdiplus.dll
Version: 6.1.7600.16385 (win7_rtm.090713-1255)
----Module Name: NCSUtil4.dll
Path:  D:\软件安装\MapWindow\NCSUtil4.dll
Version: 4,2,1,128
----Module Name: tbb.dll
Path:  D:\软件安装\MapWindow\tbb.dll
Version: 2, 2, 2009, 1011
----Module Name: MSVCP90.dll
Path:  C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4974_none_50940634bcb759cb\MSVCP90.dll
Version:
Developer
Mar 31, 2013 at 4:40 PM
You need to make sure you are passing a System.Drawing.Image object to the method. What does your code that calls AddButtonNewStyle() look like? Should be something like this:

AddButtonNewStyle("Test", false, "New Toolbar", new System.Drawing.Bitmap (@"C:\Downloads\DSC_0005.jpg"), "Label", "");

Do not use the MapWinGIS Image class.
Apr 1, 2013 at 8:18 AM
thanks a lot
Jun 5, 2013 at 3:51 AM
GuCciZhang wrote:
thanks a lot
能帮我一下吗,我也在做,遇到了一下困难