Resharper changes below code
string strTest = "Test";
string strTest2 = "Test2";
to this
string strTest = "Test";string strTest2 = "Test2";
if cursor is at the end of the first line when I start project. It makes all breakpoints obsolete ("The breakpoint will not currently be hit. The source code is different from the original version.")
And sometimes it mixes comment line with code line and completely breaks execution. For instance:
//Comment line
string strTest = "Test";
changes to
//Comment linestring strTest = "Test";
If cursor is between double quotes it doesn't modify code.
If I suspend ReSharper plugin code doesn't change on compile time so I am pretty sure that ReSharper has some problems. I tried disabling formatting on ReSharper options but it still modifies code.
How can I disable this feature? Other formatting options seems ok (Both VS and ReSharper) so if I just disable compile time auto corrections it will be ok. I couldn't find any option for this.
PS: I use VS2013 with VSCommands for VS2013 extension. ReSharper version is 10.0.2.
Solution: As #Alexander mentioned it is related to DevExpress components. Emptying the licences.licx file contents and restarting visual studio/Clean&Rebuild project resolves the issue. This prebuild-event script solves the issue.
break>$(ProjectDir)\Properties\licenses.licx
Related
I'm creating a Visual Studio 2013 plugin (ok, extension package actually) that seeks to paste certain strings* into a currently open .vb or .cs file, but when I get to the point of doing the actual pasting of text the editor instance freezes up for a while. If there are reletively few lines, VS will come back after a few seconds, but for 20+ lines the editor just never comes back.
This is the gist of what my code looks like:
String myText = "foo";
DTE dte = this.GetService(typeof(DTE)) as DTE;
EnvDTE.TextSelection selection = (dte.ActiveDocument.Selection as EnvDTE.TextSelection);
selection.Text = "";
//Here myText ends up having some content written into it
selection.Text = myText; //VS hangs after this point
Any clues as to what I can do to fix (or at least debug) this? I've tried VS's Profiler but all I get is that 98% of the time is wasted on "msenv.dll" and I can't see what's going on inside..
*(takes SQL from the clipboard and breaks it into lines wrapped in AppendLine calls to a StringBuilder)
OK, I hadn't seen this question: https://stackoverflow.com/a/1096737/1605873
Turns out, I just needed to use selection.Insert(myText); rather than selection.Text = myText; it is absurdly faster.
I am trying to create a graph with C# and the WPF chartingToolkit, I have the following code:
LineSeries lineSeries1 = new LineSeries();
lineSeries1.Title = region;
lineSeries1.DependentValuePath = "Value";
lineSeries1.IndependentValuePath = "Key";
lineSeries1.ItemsSource = points;
this.Graph.Series.Add(lineSeries1);
where points is a Dictionary<string, int> created in earlier code. This code compiles fine and runs fine until it reaches the line LineSeries lineSeries1 = new LineSeries();. Upon reaching this line it throws a Source Not Found: LineSeries.cs not found exception. I have tried putting it as System.Windows.Controls.DataVisualization.Charting.LineSeries lineseries1 = new System.Windows.Controls.DataVisualization.Charting.LineSeries(); but that failed to fix the issue. Everywhere I look for examples of how to do this it is written exactly how I have it.
EDIT:
It works perfectly without the debugger. The problem only exists with it.
The debugger was looking for a source file but was not able to find it. This will have been either because you don't have it available or because the version of the source you have does not exactly match the version which was compiled into your library.
If the latter is the case, you can work around it by going to Tools -> Options -> Debugging and unchecking the "Require source files to exactly match the original version" option.
Me and some of my colleagues are working on a project together, and have encountered a weird issue we can't manage to fix.The project involves the creation of a VNC connection between a client and a server, and is written in C# (we're using Visual Studio 2010). We're using the VNCSharp library for the client.The issue I speak of is that once we start the connection with the server, an ArgumentException is thrown.
Some of the information supplied was this:
********** Exception Text **********
System.ArgumentException: Parameter is not valid.
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at VncSharp.RemoteDesktop.SetupDesktop()
at VncSharp.RemoteDesktop.Initialize()
at VncSharp.RemoteDesktop.Connect(String host, Int32 display, Boolean viewOnly, Boolean scaled)
at VncSharp.RemoteDesktop.Connect(String host)
at RemoteDesktopTest.Form2.startConnection()
Another weird thing about this is that it only occures some of the times, whereas in others it works perfectly well. Specifically, it always works when run in debug mode (i.e, when we run the program line-by-line using F11), and either works or doesn't work when run regularly (i.e Ctrl+F5), without any pattern we could recognize.
We would be really grateful for any and all help; if there are any details I can add that would assist in the answering of this question, please let me know.
Additionally, I apologize for any grammar/spelling mistakes; English is not my first language... and I also apologize if something about this question is not alright. We're all beginners and this is our first "big project", so this is also my first time asking a question in Stack Overflow.
EDIT:
There are some parts of the code that are potentially relevant.
These are the lines of code automatically generated after we added the VncSharp control to the form and customized its settings:
this.remoteDesktop1 = new VncSharp.RemoteDesktop();
this.remoteDesktop1.AutoScroll = true;
this.remoteDesktop1.AutoScrollMinSize = new System.Drawing.Size(608, 427);
this.remoteDesktop1.Dock = System.Windows.Forms.DockStyle.Fill;
this.remoteDesktop1.Location = new System.Drawing.Point(0, 0);
this.remoteDesktop1.Name = "remoteDesktop1";
this.remoteDesktop1.Size = new System.Drawing.Size(1113, 580);
this.remoteDesktop1.TabIndex = 1;
This is the line of code in which I call the Connect method, while IP is simply the string taken from a text box:
remoteDesktop1.Connect(this.IP);
These are from the method which handles the ConnectComplete event (e is the EventArgs object passed to the method):
this.Location = new Point(0,0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;
this.remoteDesktop1.Size = new System.Drawing.Size(e.DesktopWidth, e.DesktopHeight);
Aside from the line in which the Disconnect method is called, we've written literally no other lines of code that deal with this object. If I'll realize I'd forgotten something, I'll edit again and add it. Also, if there's anything specific in the code I should add here, please let me know.
The issue was related to timing, it seems.
Out of debug mode, the program ran too fast and those width and height variable didn't have their values updated.
Luckily, VncSharp is open source, so I could add my own line and leave it in a loop as long as either of those two variables still has its default value, and now it works.
Thanks for the help, everyone :)
Had the same problem. For me it worked to compile the vncsharp solution in debug mode.
In RfbProtocol line 398 (first line of the ReadServerInit method), I transformed
int w = Reader.ReadUInt16();
to
int w = 0;
while (w == 0)
w = Reader.ReadUInt16();
I am trying to use Settings.settings to define/persist some vars. For brevity, I've set up a test file to demonstrate the behavior I'm seeing:
First, I define a setting in Settings.settings:
I then have the following code to test changing variableName:
public Form1()
{
InitializeComponent();
string newString = Properties.Settings.Default.variableName;
Properties.Settings.Default.variableName = "This is a new string";
Properties.Settings.Default.Save();
}
Running the above in the debugger for the first time, I grab the current value (the value I set in the Settings.settings window initially) of variableName from Properties.Settings. As expected, newString is set to "This is a string". Good.....
After executing the next two lines, the debugger shows variableName changed to "This is a new string". Good....
I then run the app through the debugger again. I hit the string newString line and, prior to execution, newString is undefined (of course). Good....
As soon as I execute...
string newString = Properties.Settings.Default.variableName;
... and on subsequent executions of the code, the actual value of variableName is defined as "This is a new string" (Good...as expected).
I then go back to the Settings.settings window. variableName has not changed - it's still "This is a string". I've even closed VSE 2012 and re-opened the project. Settings.settings never changes.
Where is the new value being stored? I've checked all of the .config files ([appname].exe.config, [appname].vshost.exe.config, app.config, and the Settings.settings file) and the new value, "This is a new string" isn't anywhere to be found.
In summary, I'm getting the result I desire from the code, but I can't seem to view the result at design time other than to check the value of the var in the debugger. This seems not only peculiar to me, but impossible.
What am I missing/where am I not looking? I would fully expect the value of variableName to change in the Settings.settings window, but it never does. I've looked everywhere on StackOverflow/Google and can't seem to find the answer.
Thanks in advance....
The original value that you configured via Settings.settings is stored in a .config file alongside your executable's assembly. This will never change unless you modify the Settings file directly via Visual Studio; it's essentially a read-only file.
The user's customized setting is stored in a separate config file within the user's profile. The location of this file depends on your assembly's metadata. For example, on Windows 7/Vista the location might look like:
C:\Users\<user name>\AppData\Local\<company name>\<assembly name>\
AssemblyName\<version>\user.config
If you haven't customized the company name in your assembly's metadata then it may default to Microsoft. Also note that AppData is a hidden folder that may not be visible in Windows Explorer depending on your view settings.
I am not sure if I understand your question. That variable content stay persistent. Thats it. Why you would set a persistent variable to change it later?
Edit: I just tried this with VS 2010, and the problem didn't occur. The issue only happens with VS 2012. Could this really be a bug? This is also happening on two separate laptops of mine, and even on a friend's laptop (that just got the latest code).
First, a screenshot of the problem. This method is all new code.
The debugger is skipping code from my recent check-in. The comments, in the code below, explain what is happening when I debug this method. So there really isn't a need to try and understand the code; just notice that lines of code are being skipped. If you're thinking that the code doesn't match the assembly being debugged, please bear with me. You'll see where the debugger recognizes new code, but not existing code. And this behavior is occurring on two different laptops, after deleting the code on disk and getting the latest again. Each comment tells you if the debugger hits a line.
[TestMethod()]
[DeploymentItem("PrestoCommon.dll")]
public void ApplicationShouldBeInstalledTest_UseCase9()
{
// Debugger hits this line
ApplicationServer appServerAccessor = new ApplicationServer();
// Debugger does not hit these next two lines
PrivateObject privateObject = new PrivateObject(appServerAccessor);
ApplicationServer appServer = ApplicationServerLogic.GetByName("server10");
// Debugger hits this line. Weirdness: both objects are null, and after this line runs,
// appServerAccessor is no longer null.
appServerAccessor.Id = appServer.Id;
// Skips this line
ApplicationWithOverrideVariableGroup appWithValidGroup = appServer.ApplicationsWithOverrideGroup[0];
// Debugger hits this line, but F11 doesn't take me into the method.
appWithValidGroup.CustomVariableGroup = CustomVariableGroupLogic.GetById("CustomVariableGroups/4");
// Skips this line
Assert.AreEqual(true, true);
}
The disassembly shows only the lines of code that actually get hit.
Now, check this out. If I add a new line of code, the debugger recognizes it, and the other lines of code change, as far as being recognized by the debugger. Just the second line of code, within the method, is new.
[TestMethod()]
[DeploymentItem("PrestoCommon.dll")]
public void ApplicationShouldBeInstalledTest_UseCase9()
{
// Debugger hits this line
ApplicationServer appServerAccessor = new ApplicationServer();
// New line. It's recognized by the debugger, and it shows up in the disassembly.
if (DateTime.Now > DateTime.Now.AddHours(1)) { return; }
// Debugger does not hit these next two lines
PrivateObject privateObject = new PrivateObject(appServerAccessor);
ApplicationServer appServer = ApplicationServerLogic.GetByName("server10"); // Gets hit now.
// Debugger hits this line. Weirdness: both objects are null, and after this line runs,
// appServerAccessor is no longer null.
appServerAccessor.Id = appServer.Id; // No longer gets hit.
// Skips this line (now it's getting hit)
ApplicationWithOverrideVariableGroup appWithValidGroup = appServer.ApplicationsWithOverrideGroup[0];
// Debugger hits this line, but F11 doesn't take me into the method. Now this gets skipped.
appWithValidGroup.CustomVariableGroup = CustomVariableGroupLogic.GetById("CustomVariableGroups/4");
// Skips this line. Still skipped.
Assert.AreEqual(true, true);
}
And here's a partial snapshot of the disassembly, showing the new line of code:
How can this be happening?
Adding to the weirdness, at one point this even returned:
if (DateTime.Now > DateTime.Now.AddDays(1)) { return; }
Things I've tried:
- Delete source code from hard drive and force a get latest
- Repair VS 2012
- Do some VS clean-up
- Use VS 2010, change code, check in, get latest with VS 2012
- Reboot
- Other (can't remember all of them)
This appears to be unit-test specific. In VS 2012:
Test > Test Settings
Open the selected test settings file
Data and Diagnostics > deselect Code Coverage (Visual Studio 2010)
Apply
Note, I had the advantage of access to the source code, and I downloaded Presto (http://presto.codeplex.com/).