Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7645001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:49:40+00:00 2026-05-31T09:49:40+00:00

I use This to create a Config file generator, in other C# Form project

  • 0

I use This to create a Config file generator, in other C# Form project I add the ini Class of the Config file generator project, create 2 not visible textboxes and use the ReadValue of the Config generator project to read the urls created by the Config file gen previously; This project uses a Uri to download a file and I want that Uri to be the not visible textbox text (That is a url in the config file) but when I do

IniFile ini = new IniFile("C:\\Config.ini");
TextBox1.Text= ini.IniReadValue("Config","Patch URL");

to write the Uri (private Uri PatchLocation = new Uri(TextBox1.Text);)
Says “A field initializer cannot reference the non-static field, method, or property ‘Downloader.Form1.TextBox1′”.
What I need to do for make the Uri be the TextBox text then?
Hope someone could help me, because I really need to do that. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:49:42+00:00Added an answer on May 31, 2026 at 9:49 am

    Instead of private Uri PatchLocation = new Uri(TextBox1.Text); try

    private Uri PatchLocation
    {
        get
        {
            return new Uri(TextBox1.Text);
        }
    }
    

    Basically, the code you have currently is saying “when I initialize this Form1 object, set PatchLocation to what I get from Textbox1” which isn’t what you want – and the compiler won’t let you do it anyway.

    The code I’ve given is a property, which means it won’t read the contents of Textbox1 until you try to read PatchLocation. Every time you try to read PathLocation, it will parse the value out from TextBox1.Text. It will throw an exception if that value isn’t a valid URI at the time.

    Edit: Actually, having fully read your question, you’d be much better off at least removing the hidden textbox and using

    private Uri PatchLocation
    {
        get
        {
            IniFile ini = new IniFile("C:\\Config.ini");
            return ini.IniReadValue("Config","Patch URL");
        }
    }
    

    unless you have a really compelling reason to be using a hidden textbox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this tutorial to create a login form http://www.ryancoughlin.com/2008/11/04/use-jquery-to-submit-form/ It authenticates against
I'd like to use this method to create user-friendly URL. Because my site is
may i know how to use this getMicrophone with simpleFLVWriter to create flv with
I want to use this for an object factory: Given a string, create a
I have create name range on sheet A so I need to use this
I want to create conditional comments in XSLT. But when I use this: <!--
I was wondering, why do static Create methods exist? For instance, why use this
this question can create a misunderstanding: I know I have to use CSS to
This is a design question: when do I need to create/use a static method
i have this crazy label for each time i create a migration that use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.