System.InvalidOperationException is scaring me - vb.net

I recently reset my whole laptop. After the reset, I installed all of my programmes, including Visual Studio 2013 (I had 2012 on my last build). I then dumped my projects into the projects folder of 2013 and...I COULDN'T RUN MY PROJECT!!! I can view the code and the designer but I can't run it.
The error is from Application.Designer.vb and it is a "System.InvalidOperationException" error. Under additional information, it says "An error occured creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. Highlighted is Me.MainForm = Global.MyApplicationName.Form1
I have checked msdn for answers about System.InvalidOperationException but haven't found any fixes that work.
I really don't know what to do and don't want to lose my application as I've spent a fair bit of time on it.

I have 2 suggestions to try
Open Application.Designer.vb and just delete the word Global.
Exclude (not delete) the mainform (Form1, apparently) from the project. Save it. Then include it again and go to Project Properties and make it the startup form again.
I've had similar issues (without the exception) when reorganizing pieces of large solutions into other namespaces. Often, I need to drill into the designers to change a ref to get it to run and it is usually removing 'Global' and/or adding the new Namespace ref. In your case, it sounds like a similar reference in the project did not get updated from 2012.
If that is the case, the second way should get VS to write back all the files in a manner that it likes.

Related

Visual Studio 2022 Corrupt Designer.vb File

This is a cry for help.
I have spent many hours working on a program and today it just didn't load up in VS properly.
As far as I can see the designer file for the project just doesn't work.
The problem is I have added various buttons and controls to a windows form and all the controls are showing an error. Shown Below are some of the errors.
Error BC30451 'NotifyIcon1' is not declared. It may be inaccessible due to its protection level.
Error BC30451 'ToolStripPref270Degrees' is not declared. It may be inaccessible due to its protection level.
Error BC30456 'Show' is not a member of 'Main'.
Error BC30451 'ListBox1' is not declared. It may be inaccessible due to its protection level.
Error BC30451 'ListBox2' is not declared. It may be inaccessible due to its protection level.
Error BC30456 'Hide' is not a member of 'Main'.
Error BC30590 Event 'Load' cannot be found.
I have tried what most posts I can find are saying how to fix this but nothing is working.
looking in other designer files it seems totally different from what this designer file looks like. Other files have lots of text about the controls but this one has everything saying locked after the control. like below.
Public Shared ReadOnly Property Button1_Locked() As Boolean
Get
Dim obj As Object = ResourceManager.GetObject("Button1.Locked", resourceCulture)
Return CType(obj,Boolean)
End Get
End Property
it's took me an age to get this program working and i feel like trashing my pc after this. i've been trying to fix it since 5 hours at least. I read that if you delete the designer file, vs will regenerate one but that's just not happening. when i load the solution the designer window just doesn't load and i cant see any option to get it to load anywhere like some posts i've read are saying. Stopping short of just starting again, I come here look for help.
My question is how do you regenerate or fix a corrupt designer file in Visual Studio 2022 ?
Thanks for any help anyone can give.
edit:
The designer could not be shown for this file because none of the classes within it can be designed.
at Microsoft.DotNet.DesignTools.Client.CodeDom.CodeDomManager.GetDeclarations()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.PerformServerLoad()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
After figuring out how to replace the broken designer.vb file with a blank one that allows the designer to load, I get these errors above when trying to save the file.
again thanks for any help anyone can give.

DisconnectedContext was detected:Exception setting can be set for a project?

When i run one of my vb project i get below warning message.
DisconnectedContext was detected
Message: Context 0x21b448' is disconnected. Releasing the interfaces from the current context (context 0x21b2d8).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.
A quick google search gave me result like it can be solved by disabling the exception "disconnectedContext ". So I did in menu->debug->exception, under manage debug assistants deselect disconnectedContext and it solved the problem too.
But this setting is not project wise or visual studio wise. I found like this setting is saved in .suo file.Now I want this setting I made to be available for all users using the project. So how it can be set project wise so that all users using the project will be able to get disconnectedContext setting disabled

entity framework keeps generating 2 separate class files which leads to conflicting names

i'm using vs 2012- ef 5 working with model first approach, and the ef keeps on creating tow separate class files for each entity, one is as sub item under the model.tt file, and the other is within the model.designer.vb file.
i'v tried everything, and searched the web, but found nothing, even after entering the error code and desc. in msdn.
i'v also tried to remove the .tt file, but that lead to an exception and i got a message that "visual studio cannot locate the file ...tt"
i will really appreciate help, because i can't go on with my app.

Custom ifilter for sqlserver works only for first file

I created a custom ifilter for a new extension (.abc).
When I installed it in operative system, the search works well.
When I tried to use it in sqlserver 2012 on a full text index on a filetable table, I saw that only one file was indexed correctly.
I tried to debug the indexing task attaching the debug at fdhost.exe. I saw that my class was instantiated and destroyed exactly as many times as the files .abc in the table, but only the first time I saw calls to IPersistFile::Load, IFilter::Init, IFilter:GetChunk, IFilter::GetText, next time only constructor and destructor was call on my class.
Also, in next time, after call to constructor I see in output window of visual studio 2012 an exception:First-chance exception at 0x000007fefd44a49d in fdhost.exe: Microsoft C++ exception: CNLBaseException at memory location 0x01022c30.
I haven't found any documentation on this error and on behaviour of fdhost in order to understand where the error is.
Thank you for answer.
Luigi

"File Not Found" in MSBuild Community Tasks -- Which File?

I'm trying to use the VssGet task of the MSBuild Community Tasks, and the error message "File or project not found" is beating me with a stick. I can't figure out what in particular the error message is referring to. Here's the task:
<LocalFilePath Include="C:\Documents and Settings\michaelc\My Documents\Visual Studio 2005\Projects\Astronom\Astronom.sln" />
<VssGet DatabasePath="\\ofmapoly003\Individual\michaelc\VSS\Astronom_VSS\srcsafe.ini"
Path="$/Astronom_VSS"
LocalPath="#(LocalFilePath)"
UserName="build" Password="build"
Recursive="True" />
If I write a Streamreader to read to either the database path or the local path, it succeeds fine. So the path to everything appears to be accessible. Any ideas?
Two thoughts. One, sometimes a type load exception manifests as a FNF - let's hope that's not it. But if the code is actually being honest, you can track the problem using Procmon or Filemon. Start one of those utilities and then run your task again. You should be able to track down a record of a file that couldn't be located.
#famoushamsandwich that's a great response -- I had not previously heard of procmon or filemon. Tried procmon on the problem, but even after sifting through the relevant output (my gosh the machine does a lot more stuff behind the screen than I was aware of) I couldn't find where a file I'm referencing wasn't being found.
Procmon and Filemon are good suggestions - just make sure you filter the results to only show errors. Otherwise the success messages will bury the problem entries. Also, you can filter out processes that are not at fault (either through the filter dialog or by right-clicking the entry and choosing "Exclude Process".)
A couple other thoughts:
In the LocalFilePath, you are specifying a single file as opposed to a folder. The task, on the other hand, specifies to get files recursively. Perhaps you need to remove "\Astronom.sln" from the LocalFilePath?
Is the build task being run under your account or another? It's possible you have a permissions issue
Do you already have a copy of the code pulled down in the same location? Perhaps there is a failure to overwrite an existing file/folder?