How can I compile a Visual C# 2008 program that includes an access database? - c#

I have tried creating an install file but it never includes the database in the output, I have run into this problem a few times and most of the answers I find online are too cryptic for me to wrap my head around.

In the Project menu, select Add existing item, change the file type to Data Files and select your database. Then go to your project properties, in the publish tab, click the Application Files button and make sure your access file is include.

If you include your MDB as a resource (Properties -> Build Action -> Embedded Resource) you can extract it using: Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
See here for a complete sample (that also decompresses):
http://code.google.com/p/videobrowser/source/browse/trunk/MtnFrameGrabProvider/Plugin.cs

Related

What is .wsuo file?

In my project, while cloning existing repository, there is immediately added one new file.
What is that? Am I allowed to push it or should I ignore it in .gitignore?
There already exists .suo file...
Could the reason be that I have installed the newest Visual Studio version?
From official MS Docs:
The solution user options (.suo) file contains per-user solution options. This file should not be checked in to source code control.
The solution user options file is used to store user preference settings, and is created automatically when Visual Studio saves a solution. So need to worry. Even if you delete this, it will be auto generated on the very next build.
Moreover, it should not be checked into source code. So in your .gitignore file, you should its reference as well:
.wsuo

Can only add database, text file or xml file to ASP.net project

So I'm running into this problem with my Visual Studio project.
I'm trying to add a new simple class to my project. I'm pretty sure this is the way to do it.
So whenever I click New Item, this menu pops up:
I can't seem to add anything other than those files. Changing tabs doesn't help. All of them are empty, except for the data tab, which contains The Sql Server Database, XML File and XML Schema. The general tab contains the Text File option.
Any help from you guys is appriciated!
The problem was that my files were stored in the App_Data folder that had been automatically generated. It apprears to be meant for data storage and not logic.
If you have the same problem, move your files to e.g. a Helpers folder.
You can actually add the file upon clicking Add option, there is a class option here:
Regarding additional templates, you can refer to this link for solution:
no templates in Visual Studio 2017

How can you add external info to C# program during build?

I want to add a small piece of information such as a software package version I have on my machine to my C# executable.
I want this info pulled on the fly during every build of my program. The info is just 1 line in a text file saved somewhere on C:\
The info needs to be accessible to my program, when I click a button within it, it should display that line of text it grabbed during the build.
Perhaps this could be accomplished by putting the info into a custom environment variable, which gets propagated during a build by adding a before build target. Not sure how to do that, if its even possible. Im using VS2008.
Please share your ideas!
VStudio has the option of performing pre-build steps. In our build, we have a batch file that executes tools that in turn generate a small file of C# which is then built by the build process. It's not very elegant, but has the benefit of simplicity and it works.
If you are the only person to be building this (or everyone building it has this text file in the same location), you could add your text file to your project as a linked item.
This way the file would be included with your project without creating a copy so any updates to it would be propagated to your project.
Right-click the project in solution explorer
Add->Existing Item...
Once you have navigated to your text file, click the down arrow icon at the right edge of the add button and select "Add as Link"
These steps are copied from this answer to a different question. That question was dealing with VS2010, but this should work in VS2008 just the same.

What is the best way to duplicate a .csproj (for creating the same app with different named exes)?

I have a solution in visual studio where one project (.csproj) is set to create an exe.
I would need to create a duplicate copy of this project so that I can name it something different and change the icon for it. (All of the rest of the projects can stay the same)
I am using conditional compilation symbols for that project, but I don't want to create a whole separate solution configuration because that requires expensive rebuilding of the entire solution.
In Visual Studio under Build -> Configuration Manager, you can create a new configuration for your project and clone it from your release build, then in your project properties you can customize it.
For the icon, you'll want to refer to Set a different ApplicationIcon for each build configuration
Create a copy of the project on disk (outside Visual Studio) and add the copied project to the solution. Then you can modify output assembly name, icon. etc..
However better practice would be to perform the necessary operations as postbuild step (e.g. batch/powershell script) as you will have to keep the projects synchronized (added/renamed/removed files, references...)
Copy it somewhere else and change the assembly name and namespace may be on the project property window( right click and property)
I dont know what your trying to accompish but possible solutions:
add post build event that will copy exe / (exe ad dll-s) to another directory
if you use TFS, edit your Build so it will create copys
Cheerz,

Unable to access 'Build Action' property for .cs files

i got a problem with my site with my app_code files and a lot of question ive read people say you need to change the proprties of the .cs files to Build Action.
by right clicking the .cs files and press proprties.
but...
when i right clicking the files i cant see any option called proprties so i press F4 and it open a proprties window and i just click on the .cs file and still cant see any option i can change somthing to Build Action.
any idea why i cant see this options?
EDIT:
my problem is that when i get in the file proprties i have only 2 options...
thay are called:
1.Full Name
2.Full Path
EDIT2:
here what i see in visual studio 2010 when i try access the protrtie menu/window
http://img338.imageshack.us/img338/2359/blac.png
As Microsoft points out in the article "Web Application Projects versus Web Site Projects":
Web application projects use Visual Studio project files (.csproj or
.vbproj) to keep track of information about the project. Among other
tasks, this makes it possible to specify which files are included in
or excluded from the project, and therefore which files are compiled
during a build.
An answer to a similiar question at CodeProject's forums reveals a hint. Abstract:
[...] Looks like you are working on a web application that is actually a
Website as per Visual Studio. You would need to create a new Web Application
and probably copy over the source files there. [...]
http://www.codeproject.com/Questions/173637/Setting-Build-Action-for-Files-in-App_Data
Have you tried this:
You say you haven't got the option being suggested by other posters.
If this is the case, than it is quite possible that your Visual Studio settings are corrupt; this can give rise to all sorts of odd behaviour.
I would suggest you reset your settings, but please be aware you will lose any custom IDE settings that you've previously applied.
Try this:
In Visual Studio, go to Tools->Import and Export Settings
Choose "Reset All Settings" and click Next
Choose to save your current settings if you wish, or select "no" and then click next.
Choose the collection of settings( he IDE preset) you want, probably "Visual C# Development Settings"
Visual Studio will now revert all settings. Hopefully this will make the Build Action reappear.
[EDIT]
It might be worth trying safe mode too.
To do this, start up a "Visual Studio Command Prompt" from your start menu/programs list in Windows, and start Visual Studio with
devenv.exe /SafeMode
Does this make the options appear?
You can copy the file from Windows Explorer and paste it in the Solution Explorer. It will replace (or do nothing but incorporating it in the proj file) the file and recognize it as C#.
Normally you should see a Property named "Build Action" in the first line of the Property Window. This property should be set to "Compile".
Please select file and right click on it so that you will get following screen
Than click on the Properties you will get following screen
You can find build option in as a first option.

Categories

Resources