I have this C# code in Visual Studio 2013. It uses a third-party library but I don't know if that's a factor in this problem. The code builds and executes perfectly. But there's a variable in it that I can't examine in the debugger. Here's the entire routine . . .
private void AddGeometry()
{
var simplePositions = CreateRectShape(startPosition: new Point3D(0, 0, 0));
var simplePositionCollection = new Point3DCollection(simplePositions);
int size = simplePositionCollection.Count;
MainViewport.BeginInit();
MainViewport.Children.Clear();
var polyLineVisual3D = new Ab3d.Visuals.PolyLineVisual3D()
{
Positions = simplePositionCollection,
LineColor = Colors.DarkOrange,
LineThickness = 2,
Transform = new TranslateTransform3D(0, 0, 0)
};
MainViewport.Children.Add(polyLineVisual3D);
MainViewport.EndInit();
}
If I breakpoint at the Children.Add() statement and try to examine polyLineVisual3D or place a quickwatch on it, I get...
The name 'polyLineVisual3D' does not exist in the current context
... from Visual Studio. I have no trouble examining other local variables like simplePositions or simplePositionCollection at the same breakpoint.
Related
I'm unable to see local variable result within Locals windows of MS Visual Studio, all the other variables and their types display just fine.
Control is already at line 33 but I don't see effect of line 29 (refer to the image)
Code for line 28 and 29
let dataContractJsonSerializer = new DataContractJsonSerializer(typeof<List[]>)
let result = (dataContractJsonSerializer).ReadObject(memoryStream) :?> List[]
Edit - as per request for more code
[<DataContract>]
type List= {
[<field: DataMemberAttribute(Name="href") >]
Href: string
}
service call
let response = request.GetResponse() :?> HttpWebResponse
use reader = new StreamReader(response.GetResponseStream())
use memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(reader.ReadToEnd()))
let result = (new DataContractJsonSerializer(typeof<List[]>)).ReadObject(memoryStream) :?> List[]
Update: It looks like it's not appearing because of optimization.
Quote from https://msdn.microsoft.com/en-us/library/aa309368(v=vs.71).aspx : "The effect of the optimization is to remove the code related to variable z, which is never used. Note also that the Locals window does not contain a node for the variable z."
private void InitializeComponent() {
...
int j = 10, k = 20, z = 0;
for (int i = 0; i < 10; i++) {
z = j+k;
btnNumbers[i].Size = new Size(30, 30);
btnNumbers[i].Click += new System.EventHandler(btnNumbersClicked);
}
...
If you could, please paste the complete code rather than just two lines.
That being said, this works for me. It's possible you left out DataContracts and DataMember from your class.
I'm struggling to get my application out of break mode, here is what happened:
This was my code and everything worked ok:
Engine btEngine = new Engine();
btEngine.Start();
LabelFormatDocument SerialPlate = btEngine.Documents.Open(#"C:\Afrisoft\Labels\ItemLabel_General.btw");
LabelFormatDocument BoxLabel = btEngine.Documents.Open(#"C:\Afrisoft\Labels\BoxLabel_General.btw");
SerialPlate.DatabaseConnections.QueryPrompts["JobNumber"].Value = textBox1.Text.Trim();
BoxLabel.DatabaseConnections.QueryPrompts["JobNumber"].Value = textBox1.Text.Trim();
Result SerialPlateResult = SerialPlate.Print();
Result BoxLabelResult = BoxLabel.Print();
btEngine.Stop();
Then I changed it to the following as the documentation suggested:
using (Engine btEngine = new Engine(true))
{
LabelFormatDocument SerialPlate = btEngine.Documents.Open(#"C:\Afrisoft\Labels\ItemLabel_General.btw");
LabelFormatDocument BoxLabel = btEngine.Documents.Open(#"C:\Afrisoft\Labels\BoxLabel_General.btw");
SerialPlate.DatabaseConnections.QueryPrompts["JobNumber"].Value = textBox1.Text.Trim();
BoxLabel.DatabaseConnections.QueryPrompts["JobNumber"].Value = textBox1.Text.Trim();
Result SerialPlateResult = SerialPlate.Print();
Result BoxLabelResult = BoxLabel.Print();
I inserted a break point at:
using (Engine btEngine = new Engine(true))
and then when I took the break point away to test that part as well the app keeps crashing at that point. I've re-added the reference, changed the code back to the when it did work, but nothing fixes it.
Please help.
Looks like the library broke, reinstalling it fixed the issue
I'm wondering if there's a shortcut so that if I have an Complex object, I can do
var myObject = new SomeObject() {
then type a shortcut so I get this:
var myObject = new SomeObject()
{
Name = "",
Age = 0,
Height = 0,
etc.
}
As it would speed up my development time massively. I do a lot of stuff with SOAP and some of the objects have 20-30 properties in.
Intellisense is great to bring them up one by one, but if you need to skip some then you start having problems.
I have Resharper, if that adds an option also.
Can anyone point me to an example of how to programatically create a statechart in visio?
I can create blank pages, drop shapes, open template etc, but when I try to add transitions it complains that the page is not the right type.
Can't find a sample anywhere.
Alternatively: I can save the user actions to create the chart as a macro. Can I run that programatically?
Thanks.
< edit >
Step away from the PC for 2 minutes and you realise you should have put the code snippet in the question and not try to put it in comments. Forest: meet trees...
Visio.Document umlStencil = visioApp.Documents.OpenEx(#"UMLSTA_M.vss", (short)VisOpenSaveArgs.visOpenDocked);
Visio.Page page = visioDoc.Pages.Add();
Visio.Shape s1 = page.Drop(umlStencil[#"State"], 5.0, 5.0);
Visio.Shape s2 = page.Drop(umlStencil[#"State"], 5.0, 5.0);
Visio.Shape transition = page.Drop(umlStencil[#"Transition"], 1.0, 1.0);
As you can see, pretty similar to the snippet in the answer below.
< / edit >
This is the code that I ran with Visual Studio 2010 against both Visio 2007 and Visio 2010.
var visioApp = new Visio.Application();
// Load the UML Statechart stencil (docked)
var stencil_open_flags = Visio.VisOpenSaveArgs.visOpenDocked;
var umlStencil = visioApp.Documents.OpenEx(#"UMLSTA_M.vss", (short)stencil_open_flags);
// create a new empty doc based on the UML Model Template
var doc = visioApp.Documents.AddEx("UMLMOD_U.VST", Visio.VisMeasurementSystem.visMSUS, 0, 0);
var page = doc.Pages.Add();
// Find and manually change the diagram's title
var watermark = page.Shapes["Watermark Title"];
var LockTextEdit_cell = watermark.CellsU["LockTextEdit"];
LockTextEdit_cell.FormulaForceU = "GUARD(0)";
watermark.Text = "MyTitle";
LockTextEdit_cell.FormulaForceU = "GUARD(1)";
// Find the masters we need
var state_master = umlStencil.Masters["State"];
var transition_master = umlStencil.Masters["Transition"];
// Drop the masters into the page
var s1 = page.Drop(state_master, 5.0, 5.0);
var s2 = page.Drop(state_master, 1.0, 1.0);
var transition = page.Drop(transition_master, 3.0, 3.0);
I am creating a application that store basic database connection info like host,user, password and default database name in application settings using User Scope.
I am using .net 3.5 with Visual Studio 2008
I put 4 text boxes in a user control and bound their text property to the application settings individual properties.
//
// textBox_database
//
this.textBox_database.Location = new System.Drawing.Point(103, 101);
this.textBox_database.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBox_database.Name = "textBox_database";
this.textBox_database.Size = new System.Drawing.Size(255, 27);
this.textBox_database.TabIndex = 5;
this.textBox_database.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_database;
//
// textBox_password
//
this.textBox_password.Location = new System.Drawing.Point(103, 69);
this.textBox_password.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBox_password.Name = "textBox_password";
this.textBox_password.Size = new System.Drawing.Size(255, 27);
this.textBox_password.TabIndex = 4;
this.textBox_password.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_password;
this.textBox_password.UseSystemPasswordChar = true;
//
// textBox_user
//
this.textBox_user.Location = new System.Drawing.Point(103, 37);
this.textBox_user.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBox_user.Name = "textBox_user";
this.textBox_user.Size = new System.Drawing.Size(255, 27);
this.textBox_user.TabIndex = 7;
this.textBox_user.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_user;
//
// textBox_server
//
this.textBox_server.Location = new System.Drawing.Point(103, 5);
this.textBox_server.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBox_server.Name = "textBox_server";
this.textBox_server.Size = new System.Drawing.Size(255, 27);
this.textBox_server.TabIndex = 6;
this.textBox_server.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_server;
these text boxes will get user data from users to set their own database info. i have a button that saves the modified info back to the settings file
private void button_save_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Save();
}
but the design is not being saved. any help anyone?
regards,
Anjan
To Cyril: Yes i had the code to assign modified value in properties, but then even the scope was set to "User" it said readonly. So i removed the property assignment codes.
now i brought the code back and restarted VS, it works perfect now :D silly me, i should have try this old procedure before.
Thank you Cyril.
Hmm... I remember having the same problem a few months ago in one of my projects. Unfortunately I don't recall how I solved it.
Some checks...
Try setting the property scope to User in the Project Properties.
In the code you've listed I don't see where you set the property (only see you retrieving the property). Where have you set it?