I want to add a setting that uses an enum defined in form1.vb. All the research I've done suggests support for enum type settings is built-in and handled automatically by the VS IDE ... I assume this means it's as easy as defining font or color settings. However, I'm not having much. Are any of you gurus aware of how to set up an enum setting via the Project Settings UI?
I thought that enums in VB and C# where the same or at least very similar. Then today I stumbled across a bug in our VB code. The following VB code compiles and runs with no issues:
Enum Cars Subaru Volvo End Enum
[code]....
Why does the VB version not catch the type mismatch? Are enum in VB and C# different?
is there a way to see the My.Settings of one project from within another project within the same solution?I'm guessing the answer is no, they are scoped at the project level
I have one project that manage my database connection (DBServer) and one project as the main system (MainSystem). In DBServer I store all my connection data that I already managed to my.settings (ServerName, DatabaseName, connectionString, etc). How can I get all the my.settings value in DBServer (ServerName, DatabaseName, connectionString, etc) from MainSystem?
I make project 1. I add 10 settings in the Properties->settings section.
I now make a new project. Project 2. But I want to have the same settings as project 1. It would be easier to import the settings from project1. but can this be done.
Ive seen the setting file in the explorer but this code is auto generated so if its copied into project 2 after you save its regenerated again from the properties->settings values.
I have a project that has several different interfaces (a website, a local application, and some webservices), that all use the same class library. The library is an API to a database. Some settings, like log level, database connection etc, i want to store in a single place, and I want them editable. What is the best way to accomplish this? I am concerned both about ease of editing, and ease of access for the dll, as there will be a lot of calls to it and a lot of lookups for the values. I have considered using app.config, a standalone XML file, and writing values to the registry, but I cannot find any good comparisons.
In a VB.Net project, you can use the Settings tab of the properties page to define application settings. To reference the settings in code, you use the syntax My.Settings.SettingName in VB.
On the Settings tab, you get to choose the Access Modifier. It may be "Friend" or "Public". Presumably, when you choose "Public", you are making the settings accessible to other assemblies. However, once "Public" is chosen, I can't figure out the syntax to reference the settings of one project from another. In fact, I can't observe any difference between using "Internal" vs. "Public" as the access modifier.
My question: Does choosing "Public" as the access modifier make settings accessible to other assemblies? If so, what is the syntax to reference the settings from other assemblies? If not, what does "Public" do?
I get this error Format of the initialization string does not conform to specification starting at index 34. When I take my connection string and store it in the project settings. I know that this works. Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Employees.accdb
Because if I use it like this Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Employees.accdb") conn.Open()
The connection succeeds but if I try this Dim conn As New OleDbConnection(My.Settings.Default.employeeConnection) conn.Open()
I get that error. name:employeeConnection type:string scope:application value:Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Employees.accdb
I am trying to retrieve a value saved in project A settings from project B in same solution set. Is this possible in VB.NET? If possible what namespace and function would I use?
I like the way one saves settings in VB.Net, that is, with the project properties. However, I want to develop a mobile project that includes saving some settings. Problem is that the project properties doesn't include "Settings" when developing a mobile project.
i have one project that manage my database connection (DBServer) and one project as the main system (MainSystem).In DBServer I store all my connection data that i already managed to my.settings (ServerName, DatabaseName, connectionString, etc).
I use Project Setting in visual studio 2008 and everything works correctly and save my information when the application is closed. However the information it lost when the application is Uninstalled. The information is not available with my new install.how to keep Project Settings through uninstall and installs!
Is it possible to access the My.Settings of an other DLL referenced in the current Project? I have a Database project in which Settings the ConnectionString is stored. I need access to this Setting in an other Project(for Log-File).
It must be to close to the weekend, but I thought I read at some time an article of an easy way to have a common settings file for both application and user settings across a solution.
I currently have a Solution that contains 4 projects. Each of these projects need to access the same set of settings and be able to update the user settings. Is there a way to do this utilizing the My.Settings functionality?
I just created a game program out of VBE2008 and did the build process to turn it into a .exe file.When I did the build function I apparently missed the step of attaching an icon to the project.Now when I do a desktop shortcut to the .exe file there is no pretty icon - just an ordinary looking window box.How do I add a desktop shortcut icon to inside the project settings?
The Visual Studio Settings and Project Designers Package ({67909B06-91E9-4F3E-AB50-495046BE9A9A}) did not load because of previous errors. For assistance, contact the package vendor. To attempt to load this package again, type 'devenv /resetskippkgs' at the command prompt.
I've defined a setting called CustomActions as a System.Collection.Hashtable. I also have a form with two textboxes (Name & CommandLine) that I want to add as a Key/Value pair to the CustomActions settingHowever, when I come to add the kvp to Hashtable I get the dreaded "Object reference not set to an instance of an object". I know what the error means I just don't see why it's relevant here.
Dim CustomActionForm As New DefineCustomAction If CustomActionForm.ShowDialog = System.Windows.Forms.DialogResult.OK ThenMy.Settings.CustomActions.Add(CustomActionForm.txt_CAName.Text,
Is it possible to initialize a My.Settings value in a Visual Basic Deployment Project (VS 2008)? I can add the Radio Button Dialog to prompt the user, but I don't see how to use that to set the My.Settings value.
For a Vb.net 2008 desktop application that I was just assigned to work on a new workstation, i am getting only the following compile messages:Warning 1 Use command line option '/keyfile' or appropriate project settings instead of 'AssemblyKeyFile'
Error 20 The command "C:racEnroll.app1inDebug\Enroll.app1.exe Debug" exited with code 1. Enroll.ALtot.I know the two lines are related since I have not signed the total application. The file in the 'AssemblyKeyFile' is no longer needed for this application since it is not used. Thus, can you tell me what I can do so the assembly key file is not used? If best, what can I do to get this application tio compile with no errors?
Until asking a question on here I never considered (enums) to be a "bad thing." For those out there that consider them not to be best practice, what are some approachs/patterns for avoiding their use in code?
Edit:
public Enum SomeStatus Approved = 1 Denied = 2 Pending =3 end Enum
We have legacy character codes that we want to store as numbers in a new system. To increase readibility and general understanding in the code for devs making the migration, I want to do Enums like this..
[Code]...
With this setup, the code will be readable (imagine If Record.Status = Status.Open), and yet the values will be stored in the database as small numbers so it will be efficient. However... I am a VB.NET guy, but everybody wants to code in C#, so I need this sort of structure in C#.After Googling, I discovered the the general .NET equivalent of AscW is Convert.ToInt32("C"). When I try to use that statement in an enum, I get the compiler error "Constant Expression Required".
I have an enum and a usercontrol, both in the same assembly (a plain .NET 4 web site). In the Constants class:public Enum CrudOperations Add Edit Delete. This controls the columns in a GridView on a UserControl via a property on the UserControl
[Code]...
In C#, I've specified the columns to show with markup as Mode="Edit,Delete", but in VB.NET, this does nothing. The only way I can get anything to show is with the codebehind, but if on the containing page I use userGrid.Mode = CrudOperations.Edit And CrudOperations.Delete, I get all the columns (there's also a delete column), but userGrid.Mode = CrudOperations.Edit Or CrudOperations.Delete shows nothing.
I have a public property, "Status" that is an enum. I have a setter method that changes the status and raises the PropertyChanged event. However, the WinForms user interface is not properly updating. I'm pretty sure it's because Status is an enum. Although I was thinking enum was a reference type but I guess it's a value type. Does INotifyPropertyChanged work the same with reference and value types?
I work for a web hosting company and was handed a VB script which I apparently have to compile with some updated settings by 1 of our clients who knows less about it than I do. But when trying to compile the code I receive an error "'Enums.NoticeType' is not defined". As expected I haven't a clue. Am I missing some of the code, or do I have to add some libraries in my Visual Basic 2008 Express Edition? I have pasted the line of code below. If requested I can provide the whole script.
Code: Public Function UpdateNotices(ByVal intNoticeID As Integer, ByVal strNoticeTitle As String, ByVal dtDateFrom As Date, ByVal dtDateTo As Date, ByVal intTypeID As Enums.NoticeType, ByVal boolPrimaryItem As Boolean, ByVal boolActive As Boolean) As Int32
I have a solution with multiple projects, some of the projects are written in VB, some in C#. I am wondering if there's a way to use interfaces and/or enums written in VB in C# classes? My C# code below doesn't compile, however I am able to see the interface in intellisense.
[Code]...
P.S It's a console/service application, not ASP.Net (where I know it's doable).UPD: Sorry guys, was missing a reference to the project with the interface. It's fixed now. I think the thing that in VB projects references are done slightly different than in C# confused me.
I have a base class with the the following enum and property:
[Code]...
First off, how do I do this - is it by simply overloading it? And secondly will my original property pick up the new enum automatically when using the derived class or will I need to overload that too?
We have a common component in our source which contains all the enums (approx 300!) for a very large application.Is there any way, using either C# or VB.NET, to iterate through all of them in order to perform an action on each one?
How to iterate all "public string" properties in a .net class is almost relevant but the enums I am dealing with are a mix of types.
I'm using LuaInterface for .NET to create Windows Forms objects. This works pretty good except for one thing:I want to use the Anchor property of Control to make them resize automatically. If I only set one of the Anchors (e.g. only AnchorStyles.Top), it works, but this doesn't really make sense. I have to set more than one Anchor, which is done by combining them with "bit-wise or" (or by just adding them numerically).
In VB.Net both works: Dim myLabel As New Label() myLabel.Anchor = AnchorStyles.Top[code]....
which is in a sense correct as "LuaInterface treats enumeration values as fields of the corresponding enumeration typ" (says LuaInterface: Scripting the .NET CLR with Lua).It is also not possible to assign the value as a number: