Highlighted
Absent Member.
Absent Member.
1425 views

'OdbcWrapper.Class1' threw an exception

HI,

Winform application developed using visual cobol crashes with below exception when run from windows 7 machine, but works good when run from windows 2012 server.

Only programs with ODBC connection are having this issue, rest of the other programs are working as expected in win 7 box.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.TypeInitializationException: The type initializer for 'OdbcWrapper.Class1' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: path1
at System.IO.Path.Combine(String path1, String path2)
at MicroFocus.COBOL.Runtime.Win32.PlatformAbstraction.LoadLibrary(String nativeLibrary)
at MicroFocus.COBOL.Program.ExportedSymbols.Check(MethodInfo[] globalMethods)
at MicroFocus.COBOL.Runtime.Common.ClassInfo..ctor(Type programClass)
at MicroFocus.COBOL.Runtime.Common.Global.AddProgramClass(Type programClass)
at MicroFocus.COBOL.Program.Control.Init(RuntimeTypeHandle rth)
at OdbcWrapper.Class1..cctor()
--- End of inner exception stack trace ---
at OdbcWrapper.Class1..ctor()
at WI210WRP.WI210CLS._MF_PERFORM_2526_1(_MF_LCTYPE_2& _MF_LCDATA)
at WI210WRP.WI210CLS.BusinessLayer210(String CLS210)
at WI210.WI210SCR.WI210SCR_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
WI210
Assembly Version: 1.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file://testtaris/Taris/WI210.exe
----------------------------------------
MicroFocus.COBOL.Runtime
Assembly Version: 4.0.0.0
Win32 Version: 02200.02006.0.68
CodeBase: file://testtaris/Taris/MicroFocus.COBOL.Runtime.DLL
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
MicroFocus.COBOL.Runtime.Win32
Assembly Version: 4.0.0.0
Win32 Version: 02200.02006.0.68
CodeBase: file://testtaris/Taris/MicroFocus.COBOL.Runtime.Win32.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
MicroFocus.COBOL.Tracing
Assembly Version: 4.0.0.0
Win32 Version: 02200.02006.0.68
CodeBase: file://testtaris/Taris/MicroFocus.COBOL.Tracing.DLL
----------------------------------------
MicroFocus.COBOL.Tracing.Win32
Assembly Version: 4.0.0.0
Win32 Version: 02200.02006.0.68
CodeBase: file://testtaris/Taris/MicroFocus.COBOL.Tracing.Win32.DLL
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
WI210WRP
Assembly Version: 1.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file://testtaris/Taris/WI210WRP.DLL
----------------------------------------
MicroFocus.COBOL.Sql.Loadrts
Assembly Version: 4.0.0.0
Win32 Version: 02200.02006.0.1
CodeBase: file://testtaris/Taris/MicroFocus.COBOL.Sql.Loadrts.DLL
----------------------------------------
Microfocus.COBOL.Sql.OdbcWrapper
Assembly Version: 4.0.0.0
Win32 Version: 02200.02006.0.1
CodeBase: file://testtaris/Taris/Microfocus.COBOL.Sql.OdbcWrapper.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: 'OdbcWrapper.Class1' threw an exception

What Visual COBOL version are you using?

I recall this being a problem in an earlier product release.

A more important question would be why are you using ODBC in a managed code .NET application? If you are running a managed code .NET application then you should not be using ODBC to do database connections. You should be using ADO instead.

What SQL directives are you compiling with?

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: 'OdbcWrapper.Class1' threw an exception

We are using Micro Focus Visual COBOL 2.3 Version 2.3.02188

Our new winform application makes call to native cobol programs which needs ODBC connection to execute stored proceudres. Winforms are designed as front end interface to interact with customer to collect and validate date , most of the business validation still embedded in native cobol programs.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: 'OdbcWrapper.Class1' threw an exception

The error you are receiving is for ODBC support on the managed side and not on the native side. Are you compiling your managed code application using the SQL(DBMAN=ODBC) directive as well? If you are only using ODBC in native compiled programs and not in managed then you should only be compiling the native programs using the SQL directive.

If you are setting the directive in a common COBOL.DIR file that is shared between managed and native projects then you will have to override the SQL settings in the managed projects to turn them off.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: 'OdbcWrapper.Class1' threw an exception

My solution has two projects.

Project 1 - winform  (managed template)

Project 2 - wrapper class and native cobol (managed)

First project includes winforms calling wrapper class in second project. My wrapper class calls native cobol program. So i have only included SQL directives in second project.

With this approach my program works in machine with 'cobol server' or 'visual cobol' but doesn't work across network. It fails with "OdbcWrapper.Class1 exception'

I was instructed by Micro focus support team not to combine wrapper class which is manged code with native program in same project. So i did move my wrapper class to project 1 and created a new native project which includes only my native program with SQL directives. And i did add reference to project 2. But at run time my wrapper class fails to find native program in second project

"MicroFocus.COBOL.Program.COBOLProgramNotFound: 173     Called program file not found in drive/directory'

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: 'OdbcWrapper.Class1' threw an exception

I think that there is a miscommunication here about the term "native cobol". When we use the term native COBOL we are referring to unmanaged procedural code programs that are compiled as Windows .obj files and linked as either .exes are .dlls.

This is what a native project is in Visual Studio. It generates unmanaged "non-.NET code".

You seem to be using the term "native" to define procedural COBOL programs in general whether they are compiled as native or managed code.(.NET)

If you wish to compile these procedural code programs as managed code you can do so but you should not be using the SQL(DBMAN=ODBC) directive. ODBC is a native (unmanaged) Windows technology and should only be used with native unmanaged projects. If your database vendor has an equivalent ADO.NET provider you should use this instead of your ODBC driver when compiling to managed code. Your EXEC SQL statements will behave the same but you use SQL(DBMAN=ADO) instead of ODBC and setup your ADO connection using the ADO Connection Editor.

If your vendor does not have an ADO.NET version of its driver then you should compile your procedural programs as native projects and turn on SQL(DBMAN=ODBC).

If your original configuration works on the server but not from a workstation then there is something missing on the workstation or it cannot access all of the assemblies that are required.

When you get the original error do you have your ODBC driver and your ODBC DSN setup on the workstation itself? This is required.

When you are getting the 173 error trying to call a native program from a managed program what does the call statement look like and where is the .DLL that is being called? Is the .DLL accessible within the PATH and does it have the same name as the program in the CALL statement? If it does not have the same name then you might have to load it first. You can do this by adding the $SET ILPINVOKE"progname.dll" directive to the managed program doing the call.

First we should figure out what it is you wish for your application to do.

Do you wish for it to be all managed code and is there an ADO provider available for your database vendor? What database vendor is it?

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: 'OdbcWrapper.Class1' threw an exception

Even i do agree with you that there's some system file/assembly not available/accessible when run from workstation.

My workstation has ODBC driver and DSN setup. I can still run my old dialog systems from workstation.

Here's my call statement in wrapper class : call "WI600" using by reference WRP-DATA

WI600.dll is in the same application deployment folder.

I have tried $SET ILPINVOKE"progname.dll, but now my program throws a different error

"Dynamic binding error on run-time entry point mF_ld_dynlnk_lib_check in module \\servername\share\WI600.dll"

(again this error is only from workstation)

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.