Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Austin1 Honored Contributor.
Honored Contributor.
1954 views

Error in VS after renaming form

Jump to solution

Background info:  Visual Studio 2013, Visual COBOL 2.2 Update 2, COBOL Managed, Windows Forms Application

1. Create a new project called Test as described above (a new project with a Form1 will be created)

2. In Solution Explorer, right click on Form1.cbl & use the Rename function to rename it to TestForm1.cbl

(we are just changing the name of the form)

3.  In the designer, select a label from the toolbox and drag to the form - and in the properties, Text, put a very long/large amount of text into the label as its contents (I used about 300 characters). (My understanding:  this encourages VS to make use of a "resource" file to store the label's lengthy text).

4.  Try to debug the project.  Most likely you will get this exception:  MissingManifestResourceException was unhandled

on this line in TestForm1.Designer.cbl:

set label1::Text to resources::GetString("label1.Text")

5. ... so try to fix this by stopping debugging, click on the form in designer, and in the properties for the form itself, change the (Name) from Form1 to TestForm1.  Then re-build the project and you get a build error on this line:

set resources to new System.ComponentModel.ComponentResourceManager(type of Test.TestForm1)

the error being COBCH0845 : Unknown type 'type Test.TestForm1'

in TestForm1.Designer.cbl

You can go to the project's properties and click on the Resources tab and force it to create a resources file, but that doesn't help either.

I am grasping at straws.

It appears that all of this is due to renaming the form; (and in conjunction, possibly forcing the intended use of "resources"). If you repeat the above without renaming the form, it works OK.

Note that if you were doing this in C#, when you rename the Fprm1.cs in Solution Explorer, you get a helpful pop-up box that asks if you want to fix all references, etc. to Form1, and you don't get an error when you run it.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Austin1 Honored Contributor.
Honored Contributor.

RE: Error in VS after renaming form

Jump to solution

OK.  It is understood the auto-refactoring is not [yet] past of VC.  What I was really asking was this - was there any way to even "manually" search down and change all the references to the new form name, etc.  At first, I thought that there was no way - that there were some hidden things that could not be accessed and changed.  After looking at it again, I in fact DID find some additional manual changes that I should have made related to changing the old name to the new name.  After doing all these, the program compiles and runs fine.  So just please put the auto-refactoring on a "wish list" and I will consider this incident closed.

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

RE: Error in VS after renaming form

Jump to solution

Hi Austin,

I believe the C# feature that you are referring to is Code Refactoring and Visual COBOL doesn't currently support this. Because these forms are actually made up of two source files, one generated by the designer and one code-behind file that you use that make up a single class if you rename one then you have to rename the other files as well and make the appropriate code changes to the class names within the files.

I will look into this but I would recommend that instead of renaming Form1 that you add a new Form to the project by right-clicking on the project name and selecting Add-New Item and then selecting Windows Form and then giving it the name you desire. That way it will be created with all the correct names in place. You could then delete Form1 from your project.

Thanks.

0 Likes
Highlighted
Austin1 Honored Contributor.
Honored Contributor.

RE: Error in VS after renaming form

Jump to solution

OK.  It is understood the auto-refactoring is not [yet] past of VC.  What I was really asking was this - was there any way to even "manually" search down and change all the references to the new form name, etc.  At first, I thought that there was no way - that there were some hidden things that could not be accessed and changed.  After looking at it again, I in fact DID find some additional manual changes that I should have made related to changing the old name to the new name.  After doing all these, the program compiles and runs fine.  So just please put the auto-refactoring on a "wish list" and I will consider this incident closed.

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.