I am having a solution consisting on silverlight and web project. i want to access a file which is located inside a folder in web project from my silverlight project.how can this be done.
this file is a users manual document for which i have to provide the download functionality to the user..
Right click on the Silverlight project and select Add --> Existing item.
In the dialog, navigate to the location of the web project. Select the file(s) you need but instead of clicking on "Add", click on the dropdown next to the Add button and select "Add As Link".
In your Silverlight project:
Right-click References > Add Reference.
On the left tab, select Solution.
Select which project(s) you want to include a reference to.
In Silverlight project C# files, you may have to add a 'using' statement if you are trying to use a Class from a referenced project.
Got the solutions as below,
var uri = new Uri(Application.Current.Host.Source, "../DirectoryName/FileName.docx");
HtmlPage.Window.Navigate(uri);
Related
I'm trying to use this color dialog written by someone else in my program but I don't know how to integrate it. I'm very new to C# so I am not really sure what I'm doing.
http://www.codeproject.com/Articles/33001/WPF-A-Simple-Color-Picker-With-Preview
I would recommend that for third-party code, you do not integrate their source code directly into your own project, but an assembly reference to the compiled foreign code. This makes it easier to separate your code from third-party code, and update the third-party code later on if a new version becomes available.
So this is roughly what you do.
First, create an assembly from the third-party code (the color picker source code):
Download the source code.
Open the Visual Studio solution (.sln) hopefully present in the download.
Create a Release build. (This might require you first changing the build configuration to Release via the Build menu in Visual Studio.)
After a successful build, there should now be the color picker DLL in the bin\Release folder.
2. Next, add the created assembly (.dll) into your own project and reference it:
Put a copy of that DLL into your own solution/project's directory.
In your own project, add an assembly reference to that assembly (via the Solution Explorer window's References node's context menu).
Open your project in the solution explorer, right click on References, click on Add reference, select Browse and add it.
To add an existing project to a solution:
In Solution Explorer, select the solution or the solution folder that you want to add a project to.
Right click, select Add and then choose Existing Project.
Select the project you want to add to the solution and then click Open.
To add an assembly reference to an existing
Right click on References in your project in Solution Explorer
Select Add Reference.
Select Browse and navigate to the assembly
I have a Project in which there is a form that has several objects (controls) in itself. I want to add this form to another Project in another Solution. How to I can do this. Thanks.
This is a good thing to reuse your code :)
You have to make a library project.
1)File => New Project
2)Check Visual project in the tree
then select "Class Library", give it a name "MyFormLib"
3)Then simply copy paste YourForm.cs and YourForm.designer from your app project, to "MyFormLib".
4)Now go to solution explorer, browse to your application project, right click on "references" then "add reference"
5)To finish click on "solution" then choose your library project "MyFormLib"
.
6)You can now use the form from the library project inside your application project.
e.g : new MyFormLib.TheForm()
7) To reuse your form in your second application, redo steps 4 to 6
Just simply open the project where you want to add the existing form:
Right click on the Solution Explorer
Select "Add" -> "Existing Item..."
Browse your other project's folder, and search for the 3 files of your form:
yourForm1.cs, yourForm1.Designer.cs, yourForm1.resx
The simplest way is to
Open the destination solution in Visual Studio.
On the Solution Explorer, right-click the destination Solution name and Click on Add > Existing Projects. Identify the project with your source Form.
Move the form from source to destination project (The designer and resx files will move with it)
Change relevant namespace specifications and then you may remove the old form.
I want to import an enum class (.cs) into my project that is generated by another service. So if that service will update this file, it should be automatically updated in my project. It has to be text-only (so I can't use an assembly) because we can't compile code in php.
And here is why I want this:
We are using global language strings in multiple applications and I would like to use them as enumerations for some reasons. When new texts are added I want to be able to use them without copying or changing anything. Maybe there is another way to achieve this.
Thank you.
You can add a source code file to a project as a link.
To do so:
Right-click project and select "Add -> Existing Item"
Navigate to the file you want to add as a link, and select it.
Look at the "Add" button at lower right of the "Add Existing Item" dialog. It has a little drop arrow. Click that drop arrow.
Select "Add as link".
Follow the setps:
Right click on the project go to Add
Select Existing Item
Select the file
On the Add button click the drop down button and select "Add as a Link"
Lets say I want to add a csv file to a project.
Right click on the directory in which you want to add.
Click on ADD and then Existing Item
Click on Add/Add as link , also if you are dealing with csv files or files which don't have convention extensions select All Files in that case.
c# VS2008 SP1
right Click on Project name, Add Existing Item, selecting Add As Link from the drop down menu, and selecting a .cs file outside of the project folder, causes the file to be copied locally within the project folder.
This is surely not the correct behavior?
Right Click on Project name, Add Existing Item, selecting a .cs file outside of the project folder AND THEN Add As Link from the drop down menu.
That is the default behavior. Also confirmed with Visual Studio 2010
Doesn't do that for me. Are you selecting the file you want first, and then selecting "Add as link" in the weird dropdown button?
This may be a ridiculous question for you C# pros but here I go. I'm a Flash developer getting started in Silverlight and I'm trying to figure out how to create a "codebase" (a reusable set of classes) for animation. I'd like to store it in a single location and reuse it across a bunch of different projects. Normally in Flash I would add a "project path" reference and then start using the code. My question is, how do I add a folder to visual studio so that I can "use" those classes in my project. I tried "Add > Existing Item" but that copied the files into my project directory.
The easiest way would to create a new ClassLibrary project and build it. This will output a .dll file in a folder you can specify in the project settings menus, which you reference from every project that needs it.
Also, you can copy this .dll into the /bin/ folder of your project - this will do the same thing for this specific project, but when you start the next one you can change some details in the codebase library without breaking the first project.
The solution described by Tomas (adding a reference to a dll binary) is the correct solution to this problem; better than referencing the source code and compiling it into each project.
But just for extra information, if you ever do need to add a source code file to your Visual Studio project without having it make a copy of the file you can use the following steps:
Right click on your project in Solution Explorer and select Add -> Existing Item.
Navigate to the location of the source code file and select it.
On the "Add" button in the dialog window there is a drop down arrow. Click this and select "Add as Link".
This will allow you to use this source code file in your project without having VS make a copy of the file.
In Solution Explorer, right-click on the project node and click Add Reference.
In the Add Reference dialog box, select the tab indicating the type of component you want to reference. (for instance for a class library a dll)
Select the components you want to reference, then click OK.