How to solve: System.Windows.Forms.AxHost.InvalidActiveXStateException

Hello
In the past, I developped a MapWinGIS program using C# under 32 bit. I use “axMap…”. It works perfectly.
Now I am using 64 bit (Visual Studio 2022 & MapWinGIS 5.3.0.0). I succeed to create the rebuild solution without generating error.
But when I run my program, now I get this error and I absolutely do not know how to solve it:

System.Windows.Forms.AxHost.InvalidActiveXStateException: ‘Une exception de type ‘System.Windows.Forms.AxHost+InvalidActiveXStateException’ a été levée.’

The line code n°133 where the error occurs is : axMap1.LockWindow(tkLockMode.lmLock);
It is within a procedure to “AddALayer”

Here are the details:
System.Windows.Forms.AxHost.InvalidActiveXStateException
HResult=0x80131500
Message=Une exception de type ‘System.Windows.Forms.AxHost+InvalidActiveXStateException’ a été levée.
Source=AxInterop.MapWinGIS
StackTrace:
at AxMapWinGIS.AxMap.LockWindow(tkLockMode lockMode)
at MyLib_SIG.Layer_AddOneFromPath(AxMap axMap1, ListView listLayer, String myFilePath, Boolean PathRel, Boolean Exit_OK, Boolean Exit_Msg) in C:\Users\cdela\Inexis\001 Logiciel\05 CSharp\04 MyLibrary\MyLibrary\MyLib_SIG.cs:line 133

Thank you in advance for your help.
Best regards,

Hello
Nobody has a clue to solve this problem ?
I guess that I am not the only to have trouble while passing from 32 to 64 bits.
Thank you in advance for your help
BEst regards

Hello Charly.

I’m not sure if you mentioned specifically, but are you using the 64-bit version of MapWinGIS? i.e. Have you specifically registered the 64-bit OCX?

Also, I’m not sure why your call stack seems to go from your method (Layer_AddOneFromPath) straight into the LockWindow call (without passing through the AddLayer method). Perhaps you could post that section of your code to better understand the context?

Regards,
Jerry.

Hello Jerry,

Thank you for you reply !

I am not enough advanced to understand your proposal : I don’t know what is OCX, stack call… I am just able to code a little bit C#

Here is my proposal if it is ok for you : maybe could you « take control » directly of my screen computer using i.e. TeamViewer ?

It will be much more efficient and quick. What do you think ?

Hello Charly.

I’m sorry but that would not work for me as I would not have the time to make that happen.

What would be best as a first step would be to post that section of code so that everyone can see it.

Regards,
Jerry

Hello Jerry
I understand.
Here is a printscreen of «Form1.cs(Design)»: I hope that it can help you to understand the problem. Let me know if you need other information.


Regards, Charles

I’m sorry, but I cannot read this, since it is too pixelated. Could you copy/paste the actual text?

Thank you.
Jerry.

Hello Jerry,

Here is a copy of the text for the 2 errors :

I hope that it is better.

ERROR n°1:

Could not load type ‘MapWinGIS.tkShapeDrawingMethod’ from assembly ‘Interop.MapWinGIS, Version=5.3.0.0, Culture=neutral, PublicKeyToken=null’.

|||Instances of this error (1)

  1. Call Stack
    at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
    at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
    at System.Reflection.RuntimeMethodInfo.GetParametersNoCopy()
    at System.Reflection.RuntimePropertyInfo.GetIndexParametersNoCopy()
    at System.Reflection.RuntimePropertyInfo.GetIndexParameters()
    at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetProperties(Type type)
    at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetProperties()
    at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
    at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
    at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
    at System.Windows.Forms.Design.ControlDesigner.Initialize(IComponent component)
    at System.Windows.Forms.Design.AxHostDesigner.Initialize(IComponent component)
    at System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent component, String name, IContainer containerToAddTo)
    at System.ComponentModel.Design.DesignerHost.PerformAdd(IComponent component, String name)
    at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)
    at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
    at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
    at System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.DeserializeInstance(IDesignerSerializationManager manager, Type type, Object parameters, String name, Boolean addToContainer)
    at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
    at System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(IDesignerSerializationManager manager, CodeStatement statement)
    at System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
    at System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
    at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager, String name, CodeStatementCollection statements)|
    | — | — |
    |||

ERROR n°2:

The variable ‘axMap1’ is either undeclared or was never assigned. Go to code

|||Instances of this error (1)

  1. OPAM Form1.Designer.cs Line:497 Column:1 Hide Call Stack
    at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)
    at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
    at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression)
    at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)|
    | — | — |

It looks like your paste didn’t work for some reason. Also, in addition to the 2 errors, I would like to see the source code.

Regards.
Jerry.

Sorry: I add the code in the previous message. As you can see, the program says that AxMap1 is not declared. I do not know how to solve this. I didn’t have this problem previously while I was running with 32 bits

Form1.zip (111.3 KB)
Hello Jerry, here is the code source. I hope that this will help you to understand my problem. Regards, Charles