Skip to main content

When using multiple programs with the same name in multiple projects of the 2017 Visual Studio I get "Class pgmname has multiple definitions". I've tried using a common location but that results in "resource in use". Just for testing purposes I've renamed the programs with variations of the name to avoid the multiple definitions but would like a good solution that must be available.   

When using multiple programs with the same name in multiple projects of the 2017 Visual Studio I get "Class pgmname has multiple definitions". I've tried using a common location but that results in "resource in use". Just for testing purposes I've renamed the programs with variations of the name to avoid the multiple definitions but would like a good solution that must be available.   

I would expect to see that message if you have multiple programs with the same name within the same project, or in the case where the current project defines the same name as in a referenced assembly. I think in that case the message is justifiable, as the system would not be able to determine which program is intended when the name is referenced in a CALL statement.
One solution to this might be to specify a different default namespace for each project, which can be done by specifying the ILNAMESPACE directive in the additional directives box for the project (under the COBOL tab of project properties). In this case, references to a program name within a given project will be resolved to the instance within that same project, if it exists.

Note that this use of the ILNAMESPACE directive is different from the namespace specified in the 'Default namespace' box of the Application tab. The latter is used when adding new items to the project and, if set to 'MicroFocus' for example, results in e.g.:

program-id. Program1 as "MicroFocus.Program1".
i.e. in this case the namespace is explicitly embedded into the syntax of the program.
The presence of the ILNAMESPACE directive when adding new items to a project (with default namespace) may lead to unexpected results, e.g. the doubling up of the namespace in the class name.

When using multiple programs with the same name in multiple projects of the 2017 Visual Studio I get "Class pgmname has multiple definitions". I've tried using a common location but that results in "resource in use". Just for testing purposes I've renamed the programs with variations of the name to avoid the multiple definitions but would like a good solution that must be available.   

Thanks for the info, it may still apply to my problem. But my problem describes the same program in multiple projects under the same solution. In case it makes a difference these programs are what I would call utility programs.

When using multiple programs with the same name in multiple projects of the 2017 Visual Studio I get "Class pgmname has multiple definitions". I've tried using a common location but that results in "resource in use". Just for testing purposes I've renamed the programs with variations of the name to avoid the multiple definitions but would like a good solution that must be available.   

I think my reply may have been confusing. If you have references from one project to another, and if you have the same program name in the referencing project and the referenced project, then you will see this error. Without any such references, you should only see this error if you have multiple programs with the same name in the same project.

When using multiple programs with the same name in multiple projects of the 2017 Visual Studio I get "Class pgmname has multiple definitions". I've tried using a common location but that results in "resource in use". Just for testing purposes I've renamed the programs with variations of the name to avoid the multiple definitions but would like a good solution that must be available.   

Thanks, your comment explains the behavior I'm seeing. Not all same name programs result in a conflict. They are in different legs of the solution. As for the ones that I have a conflict, I'll just have to deal with them with the technique I developed to avoid the problem i.e. same programs with different names. And a caution for anyone else reading, add a number to a 8 digit program name does not resolve the problems. A class name (program name) seems to only look at the first 8 bytes so a 9 digit program name doesn't work.

When using multiple programs with the same name in multiple projects of the 2017 Visual Studio I get "Class pgmname has multiple definitions". I've tried using a common location but that results in "resource in use". Just for testing purposes I've renamed the programs with variations of the name to avoid the multiple definitions but would like a good solution that must be available.   

Thanks, your comment explains the behavior I'm seeing. Not all same name programs result in a conflict. They are in different legs of the solution. As for the ones that I have a conflict, I'll just have to deal with them with the technique I developed to avoid the problem i.e. same programs with different names. And a caution for anyone else reading, add a number to a 8 digit program name does not resolve the problems. A class name (program name) seems to only look at the first 8 bytes so a 9 digit program name doesn't work.