Locking out Visual Studio

Prevent VS from editing auto-generated code

Page 1 of 1

8 Replies - 1840 Views - Last Post: 21 August 2007 - 11:04 AM

#1 killnine  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 161
  • Joined: 12-February 07

Locking out Visual Studio

Posted 20 August 2007 - 11:41 AM

Hey guys, I have an annoying problem

I am coding a project in C# and it contains a web browser control. The control points to a location within the install directory and to a help page coded in HTML.

However, I cant just put "/help/help_document.htm" into the address because I get an error that the argument is invalid.

However, I AM able to just type in something like:

System.IO.Directory.GetCurrentDirectory() + "\\help\\xPC Usage.htm"


by hand and it works fine. However, every time I click on the element, or REgenerate the code, it gets rewritten to VisualStudio's crappy,broken way of doing it.

Is there any way to lock the source code and keep VS out, or maybe just a way to get the webbrowser control to actually look for the page correctly.




EDIT: Here is a clarification. This works as an argument and gives me what I want:

this.webBrowser1.Url = new System.Uri(System.IO.Directory.GetCurrentDirectory() + "\\help\\xPC Usage.htm", System.UriKind.Absolute);




But the application always wants to rewrite it to this:

this.webBrowser1.Url = new System.Uri("C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\IDE\\help\\xPC Usage.htm", System.UriKind.Absolute);



What a douche....

This post has been edited by killnine: 20 August 2007 - 11:46 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Locking out Visual Studio

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,085
  • Joined: 18-April 07

Re: Locking out Visual Studio

Posted 20 August 2007 - 02:15 PM

What you are talking about has me completely confused. You do know that the GetDirectory() method returns the current working path of the application right? That is, a path name to the actual folder. I guess the confusion lies in what you mean click on the element or regenerate code. If you are talking about compiling the code, the compiler calls the GetDirectory() class and it returns a string for the path. It doesn't modify the code from the programmers standpoint.

You said that using GetDirectory() + "\\help\xPC Usage.htm" worked but kept rewriting it to the full path. Where is it rewriting it? Is your help file at another location than what it specifies when it rewrites it?

:huh:

This post has been edited by Martyr2: 20 August 2007 - 02:16 PM

Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Locking out Visual Studio

Posted 20 August 2007 - 04:12 PM

killnine I am really confused, I have been working in .Net since its inception and have yet to experience what you're explaining. Ive yet to have Visual Studio (either 2000, 2003 or 2005) "rewrite" my code for me?
Was This Post Helpful? 0
  • +
  • -

#4 killnine  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 161
  • Joined: 12-February 07

Re: Locking out Visual Studio

Posted 20 August 2007 - 06:05 PM

View PostPsychoCoder, on 20 Aug, 2007 - 04:12 PM, said:

killnine I am really confused, I have been working in .Net since its inception and have yet to experience what you're explaining. Ive yet to have Visual Studio (either 2000, 2003 or 2005) "rewrite" my code for me?


I am sorry. I was pretty unclear about that.

I have a program that just uses standard Visual Studio controls. One of those controls is a WebBrowser control. Typically, when you drag and drop a control onto a form, Visual Studio writes a bunch of properties for the control in the background.

This is the problem.

See, one of those properties is the location of the web page that is to load when the form is initialized.

When I compile my program, in the same folder as the executable is another folder (/help). In that folder is the web page I want to display within the executable.

However, Visual Studio wont let me put "/help/xPC Usage.htm" (the path of my web page) in the "address" field of the WebPage form.

So I go into the source code (my_form.designer.cs, I believe) and change the address myself (see the last two code examples from my original post).

However, Visual Studio is the entity that originally created that code, and whenever I change things in my form, it resets any code I have personally modified.

that is my problem.
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Locking out Visual Studio

Posted 20 August 2007 - 06:18 PM

killnine thats because thats code you're not supposed to touch. You dont need to change anything in the Designer.cs file, just set it in your Form_Load event.
Was This Post Helpful? 0
  • +
  • -

#6 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1865
  • View blog
  • Posts: 20,278
  • Joined: 17-March 01

Re: Locking out Visual Studio

Posted 20 August 2007 - 06:21 PM

Hah, that's why I don't answer programming questions often ;)

Carry on.
Was This Post Helpful? 0
  • +
  • -

#7 killnine  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 161
  • Joined: 12-February 07

Re: Locking out Visual Studio

Posted 21 August 2007 - 07:16 AM

View Postskyhawk133, on 20 Aug, 2007 - 06:21 PM, said:

Hah, that's why I don't answer programming questions often ;)

Carry on.



Well here is the thing:

I need to point to an html file that is in a folder just below the executable. And you can't do that in Visual Studio, to my knowledge. It just gives me a compiler error, which is ridiculous.

Any thought on how to change this behavior?
Was This Post Helpful? 0
  • +
  • -

#8 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Locking out Visual Studio

Posted 21 August 2007 - 09:10 AM

I'm not sure what version of .Net you're using but in 2.0 I dragged a WebBrowser Control onto my form (named it web) then put this down

web.Navigate(System.IO.Directory.GetCurrentDirectory() + "\\help\\xPC Usage.htm")



And got no compiler error. Have you tried this route?

Happy Coding!

This post has been edited by PsychoCoder: 21 August 2007 - 09:11 AM

Was This Post Helpful? 0
  • +
  • -

#9 killnine  Icon User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 161
  • Joined: 12-February 07

Re: Locking out Visual Studio

Posted 21 August 2007 - 11:04 AM

View PostPsychoCoder, on 21 Aug, 2007 - 09:10 AM, said:

I'm not sure what version of .Net you're using but in 2.0 I dragged a WebBrowser Control onto my form (named it web) then put this down

web.Navigate(System.IO.Directory.GetCurrentDirectory() + "\\help\\xPC Usage.htm")



And got no compiler error. Have you tried this route?

Happy Coding!



oh, I was trying to change it in that designer but I totally overlooked that I could just change it at runtime!

Thanks so much man!!!

+rep
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1