Skip to main content

I am unable to find any resources on this that resolve my issue. I'm quite new to COBOL and the dotnet ecosystem. I am on the personal edition where I've created a COBOL class library (.NET) and a C# console application (.NET). I referenced the class library project and implemented the function, but I get this error shown below.

Error

System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'MicroFocus.COBOL.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0412c5e0b2aaa8f0'. The system cannot find the file specified.
Source=SearchFrate.Core
StackTrace:
at SearchFrate.Core.Class1.Next() in C:\\Users\\repos\\ProjName\\ProjName.Core\\Class1.cbl:line 9
at Program.<Main>$(String[] args) in C:\\Users\\repos\\ProjName\\ProjName\\Program.cs:line 3

C#

using ProjName.Core;

Console.WriteLine(Class1.Next());

COBOL

class-id ProjName.Core.Class1 as "ProjName.Core.Class1".

working-storage section.

method-id Next static.
local-storage section.
procedure division returning helloWorld as string.
display "Hello, world!".
goback.
end method.

end class.


#VisualStudio
#COBOL
#VisualCOBOL
#dotNet

I am unable to find any resources on this that resolve my issue. I'm quite new to COBOL and the dotnet ecosystem. I am on the personal edition where I've created a COBOL class library (.NET) and a C# console application (.NET). I referenced the class library project and implemented the function, but I get this error shown below.

Error

System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'MicroFocus.COBOL.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0412c5e0b2aaa8f0'. The system cannot find the file specified.
Source=SearchFrate.Core
StackTrace:
at SearchFrate.Core.Class1.Next() in C:\\Users\\repos\\ProjName\\ProjName.Core\\Class1.cbl:line 9
at Program.<Main>$(String[] args) in C:\\Users\\repos\\ProjName\\ProjName\\Program.cs:line 3

C#

using ProjName.Core;

Console.WriteLine(Class1.Next());

COBOL

class-id ProjName.Core.Class1 as "ProjName.Core.Class1".

working-storage section.

method-id Next static.
local-storage section.
procedure division returning helloWorld as string.
display "Hello, world!".
goback.
end method.

end class.


#VisualStudio
#COBOL
#VisualCOBOL
#dotNet

Hi Douglas,

In order for C# to call COBOL you must also add a reference to the MicroFocus.COBOL.Runtime assembly to the C# project, if you are using the .NET Framework or you must add the MicroFocus.COBOL.Runtime.Core package to the C# project if you are using .NET (Core)  projects.

For.projects that target the NET Framework right click on the C# project's references folder and select MicroFocus.Runtime under Assemblies->extensions.

For projects that target NET (Core), navigate to Tools->NuGet Package Manager-->Manage NuGet packages for Solutions and install the MicroFocus.COBOL.Runtime.Core package into the C# project. For more information on programming for .NET (Core) please see the documentation here: