NullReferenceException in SharePoint 2010 page layout after restore - sharepoint-2010

It is SharePoint 2010 publishing website. I have a page layout with some user controls added to it. These users controls have rad editor controls in them. Everything was working perfectly unless one day I restored a backup from production to my dev and test environments. This page on dev and test environments started to give "System.NullReferenceException: Object reference not set to an instance of an object.". When I debug the controls are actually null, and debugger comes directly to set function for the fields, it does not call page_load function before coming to setter.
These same controls are working in other page layouts even after backup restore. The only difference I see in page layouts where these controls work and don’t work is AutoEventWireup="true". I tried adding this attribute to the page layout which is not working but SharePoint started to give error that this attribute is not allowed. Now no matter what I do, add or remove this attribute from my layout I keep getting error.
Another difference I noticed is that this layout was previously updated, other layouts were most probably never updated after website was migrated from MOSS 2007 to SharePoint 2010.
The only way I can make these pages work is by removing these controls from the page,
please help me find a solution to this situation. I have already read a bunch of articles about "AutoEventWireup" I am not sure if this is the problem, nothing seems to provide a solution in my current situation.

Related

why does Visual Studio modify "Windows Form Designer generated code" on designer open?

When working w/ a WinForm project in VS.NET 2015, our team has noticed that the mere act of opening a .VB form in the designer view (default action when double-clicking the file in Solution Explorer) will cause VS to modify many object properties in the "Windows Form Designer generated code" section of the actual .VB code-behind. It seems to be limited to the .Size and .Location properties for sometimes dozens or more of UI objects, always changing their X,Y coords just slightly.
Mind you we don't perform any action to drive this -- simply open the file (obtained from source-control and residing in the local solution/project) in VS.NET's form designer by double-clicking the file in Solution Explorer, and bam -- it has the "unsaved" asterisk and if you save it and compare to source control version you can see the modifications already made.
I couldn't find much on this. Is this a known behavior? Any idea why it does this? Kind of reminds me of the old days w/ MS FrontPage's designer view, and even the early days of ASP.NET in VS which would apply some HTML changes if you opened a WebForm in designer view, until they gave the option to disable that on a later release.
thanks for any input.
UPDATE: this appears to be continuing even with myself as the only editor of the .VB form in designer. various form elements are shifting their position very slightly. Here's a diff screenshot between my last check in and today, and I know I'm the only one editing:
...there are many like that. Always these two properties, always just a few pixels difference.
I don't have an specific answer for this, but since this drove us crazy a bit a few months ago with my team, while working on a WinForms project, I am glad to share my experience!
Every time someone opened any form on VS2015, it would ask other people who has the same solution open at that time to reload the code. We first thought the third party controls (at that time it was both DevExpress and Infragistics) we are using were re-generated on designed initialization - because they tend to do that a lot but then we realised this kept happening on forms that only contains .NET controls.
Now the funny part. This only happened to us on VS2015. We were using VS2013 before, without this annoying problem.
Long story short, then we realized the screens we are using have different DPIs, just like Cody Gray said. I am not absolutely sure if this was the reason, but since we started using TFS, obviously we don't have the problem anymore... Hope this helps somehow lol.

VB.2010 form not showing controls in the IDE

I have a VB.2010 Windows Desktop App that has been running for years.
As of this morning there is 1 form out of dozens of forms the app has does not show any of the controls in designer mode and not even the correct size. Look like a brand new form except the form does not any text (new form would be form1, etc.). Yesterday there was no problem.
The designer module is there as is the resx module.
When looking at the Solution Explorer showing all files the modules appear but no indented under the vb module. It is almost like VB is treating them as totally separate modules.
Went to a back of the source folder from 5 months ago and it has the same problem for the same form.
If I run the app the form does show all the controls but I am not able to see / change the controls in designer mode.
Every tried re-booting the machine.
Since the 5 month old backup has the same problem it is not something in the source. So restoring the source would not help.
Looked at another VB.2010 app that is very similar to the above that uses the 'same' forms but in a different folder and this program does NOT have the problem.
HELP!!
All the controls where there. I fixed it by removing and deleting the 'bad form'. Then doing an add existing items from a backup folder (actually created when the form was still bad).
So there is/was nothing wrong with the source and I have no idea what caused it, why backups didn't work on 2 PCs, etc. etc.
Don't know if it will stay fixed but I am ending the day (yesterday) on the above good :)
Filed in: X-Files

Forms open and load very slow. Sometimes they won't open

I have a relatively small VB winforms project.
It is currently used to launch numbers hyperlinks and some apps on a server.
There are a couple functions that do all the work, but the it really boils down to:
System.Diagnostics.Process.Start("iexplore.exe", urlVar)
or if it is an app sitting on the server, the variable passed into the function appLinkVar will contain the need file path to launch the application.
System.Diagnostics.Process.Start(appLinkVar)
The "items" are stored on a SQL Local Database (.mdf)
Id, appName, appLink, appClickCount, appFavList,anddecision, which tells the function if it is calling a website or opening an executable.
Currently, there are forty rows in the database and I project 150+ in the end that need to be updated centrally and often (weekly). But that's a different question for later. The reason I added in it in this question was for insight as to why I am using a database instead of a Setting or XML file for some links. (better suggestions welcome)
My admin main form loads Visible = False and loads the icon in the system try. So you can't actually see the first form that opens. It is a hidden admin window and it's main purpose is to put the icon in the system tray. The green RJ icon - http://snag.gy/VBa6c.jpg
Then all of the app interaction is around the notify icon. Example: the app loads on hover. right-click for settings and options etc.
Once the primary form loads, on mouse over the "Primary Label" for example and the white form to the left appears and so on. Not much to it. http://snag.gy/excKr.jpg
The Frequently Accessed items is currently stored on the database called appClickCount, this will be coming off of the database and to another recommended way of storing the data. But when I initially added the database, I noticed some lag in the main form loading. It would take it 5-7 seconds to populate the Frequently Accessed Items List and so on. So I changed the code from mainWindow.show() to mainWindow.visible(). Worked great for me. opened and closed very quickly. But after some use today by a tester, the application became almost unresponsive. He clicked on the notification icon numerous times and the app failed to load. Then threw a SQL time out error. It was the end of the day and I couldn't grab a screenshot.
I need to make this more reliable.
After some discussion the other day on SO, I was talking to someone that recommended I re-write the app in C# WPF, and that is definitely the plan. But I need this thing to past testing as is in VB this week. Where can I start troubleshooting the delay in opening? What other suggestions do you have to improve the application? Do I need to have an invisible form load first so I have access to a system tray icon or is there a better way?
I have talked to quite a few people on here lately and got some really good advice, I figured I would lay it all out here and see what input you guys can give a new guy... I'm also gonna go hang in the C# room for a little bit if you have any further questions.

How to resolve Windows Forms designer issue - controls move on debug?

Is there a reason / fix for this weird designer issue (at least, I think it's related to the designer), whereby the controls on the form do not appear as they do in the design window when I debug the application..!
Please see the following two screenshots to demonstrate the problem (note: I have blacked out some of the content of the form, this is not the problem):
Picture 1: Showing how the form appears in the designer view
Picture 2: Showing how the form appears in debug mode
You can clearly see that some of the buttons have moved position on the form.
Note: At first glance, this may appear like a duplicate of: Windows Forms Designer destroys form layout. However, I have not installed any additional tools or components. This is simply a standard "vanilla" build of Visual Studio 2012 on Windows 7 32-bit.
I've also come across this question: UI Controls Overlapping & Fonts Issue in Windows Forms Application. However, I am not using "large fonts", nor am I using any non-standard fonts on my controls (all label and button text is left as default). Still, I can see how this would affect the control positions and will do some more checks in this area.
There's nothing happening within the form's Load method.
I'm also using TFS 2012.
What could be causing this? Is there anything I can do to fix it?
EDIT: I've removed the font property for each label and button control, allowing the system to set the default value. Still no change. Interestingly, if I open the form in design mode, then save it, then close it, then open it again, the buttons have moved... If I do this a few times, the buttons migrate until they're off the form.
OK, I've found the answer, after a bit more fiddling. It seems to be related to the Anchor property on the controls. I made a bunch of changes, testing between each change to see if there was any difference. When I selected all the controls and set the Anchor property to Top, Left, this solved the issue.
I hope this helps someone else at some point!

Edit a view in Runtime

I'm developing a website with ASP MVC 3 and Razor in VS2010 SP1.
When I'm running the site from VS, if the view was open in the IDE, I can edit a view in runtime, and press F5 to show the changes, but if I open the view after run the site, then the view is locked (no message, simply I can write in the VS Editor)
When I stop debuggin the solution, the views that are locked remains locked, and I have to close the file and open id again in order to modify the code.
This behaviour is uncomfortable. Can anyone tell me why sometimes I can write in the VS2010 editor and other times I can't?
Other Notes:
The TFS is not the problem.
It happens in all the VS 2012 SP1 of my office.
It only happens in vb.net projects, not in C# proyects.
It didn't happens in VS2012.
I've disabled all the extensions.
Thanks.
I have experienced this as well.
I've found that just reopening the file, while in debug, works most of the time. The nearest thing I can figure is that you're not actually editing the file but actually viewing a debug version of the file.
This normally happens, for instance, a javascript method causes an exception within the source of that page. It then loads the active version of that page instead of the one you're editing. Though I've had it happen without any errors generated so I'm fairly certain that's not the whole issue. It might be worth posting an issue on http://aspnet.codeplex.com/workitem/list/basic It hasn't happened often enough for me to narrow it down but it sounds like it happens for you more often.
After more than a year suffering this problem, a solution was found.
This MS HotFix for VS2010SP1 solved the issue.
http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=40811