Can't add a Project Reference in Visual Studio - c#

I'm on a new PC and I wanted to do a Coding Project. I wanted to code a Console App that uses your Clipboard.
I searched on how to do that and got the answer that I should use System.Windows.Forms. But if I want to add a Project Reference, it doesn't show up the tab "Assemblies". I installed every version of .net core and framework. I just can't add a project reference. In the installation of VS I had not much Drive Space left, so I only checked the option .NET desktop development.

You have to Browse and include the file System.Windows.Forms.dll manually.
In my case, that file is in the following folder:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2

Related

SDK Rich Presence Discrod С# | Can't figure out how to create rich presence via SDK Discord

I am trying to install the Discord SDK for my C # console project for the sake of a test, but I am failing.
I have very little interaction with Visual Studio, with which I write the code, so please help with installing the SDK. I try to do everything according to what was said below, but perhaps I do not fully understand the sequence:
Open up that SDK zip that you downloaded.
Create a folder in your project directory called DiscordGameSDK and
copy the contents of the csharp/ folder to it
Build your solution then place the .dll in the directory of the .exe
(either x86 or x86_64 version depending on your compile platform).
If you compile for Any CPU you may need to perform additional
wrapping around DLL importing (like setting the DLL directory
dynamically) to make sure you load the correct DLL.
https://discord.com/developers/docs/game-sdk/sdk-starter-guide
I don't quite understand the third line of actions related to the solution, dll and exe files
Thanks in advance!
Since I'm writing in VS Code, I created a Discord Game SDK folder in my console project and moved all the files from the csharp folder to the DiscordGameSDK folder. After that, I compiled the project and transferred all the files from the lib folder to the bin/Debug/net6.0 folder
Visual Studio should work the same way. (Not sure)
enter image description here

My Visual Studio 2019 WPF app is setting a dll as the output when it should be an exe

This is my first time trying to make a deployable program. After creating a nice little WPF XAML app that runs (i.e. I can run the executable in the bin folder), I am trying to wrap it in a setup program.
After following multiple directions online for both WiX and "Microsoft Visual Studio Installer Projects". Both make installer packages, but they are only targeting the dll file from the WPF XAML output when I as for the "Primary Output". It seems this is stemming from the build of the WPF project.
How do I adjust the primary output of the build process so it is included in the setup program?
Screenshot of build output specifying the dll as the output file:
To add more details:
This could be one wpf(.net core) application instead of one wpf(.net framework). See the Output window in Elton's screenshot we can find the output is xx.dll instead of xx.exe.
If we create a Installer project in this solution, right-click the Installer project=>Add=>Project Output=>Primary output to contain the WPF's output in installer project, only the xx.dll is considered as wpf's output, but not xx.exe.
So after building the Installer project in VS, double-click the setup.exe(installer project's output), the wpf.exe is not well installed.
On top of Lance answer. You can add the publish items to your outputs near your main Primary Output.
1- Right-click on project and select Add => Project Output.
2- Choose your target project and select Publish Items from the list with your configuration.
3- Now you have another Output in your Application Folder.
Done. with every Batch Build you have your publish directory copied to application folder.
My Visual Studio 2019 WPF app is setting a dll as the output when it
should be an exe.
I'm sure you're using a WPF(.net core) project cause yesterday I happened to reproduce same situation in my machine. As for the cause of the issue, if you're interested in it, you may get some help from this issue. For .net core 2.2 and earlier, if we build a console(.net core) project, we'll get a xx.dll as output by default(Use dotnet xx.dll to run that).
But for .net core 3.0, I found this situation changes. Now if we build a Console(.net core) or WPF(.net core), apart from the xx.dll, we'll also get an xx.exe now. And I checked the Updated date of Installer Project and the Release date of WPF(.net core), the latest update of the Installer project is much earlier than the release of WPF(.net core), I guess maybe this is the cause? I'm not certainly sure how Installer Project recognize the output of one WPF project, but I suggest you can post this issue in DC forum , if it gets enough votes, the team will consider a fix.
Here're my workarounds which may help:
1.Use Add=>File instead of Add=>Primary Output:
Build the WPF project in release mode, navigate to the output path and copy that path. Then right-click Installer project=>Add=>Files to enter that path. Choose all files in output folder and click open:
Right-click the assembly file and choose Find in Editor:
Right-click the xx.exe=>Create a shortcut. Then move the shortcut to User's Desktop folder and set the AlwaysCreate property to be true.
After that, build the installer project and install that xx.msi or setup.exe in my machine, I'll get a shortcut in desktop, double-click it will run the wpf(core) application.
2.See this blog, we can use command like dotnet publish -r xxx -p:PublishSingleFile=true to get a single-file executable which is self-extracting and contains all dependencies (including native) that are required to run your app. In this situation, you don't need a Installer project to deploy your project. The single executable is enough. Hint from Lex Li in this issue.
Hope it helps :-)

How to access Windows.Management.Deployment namespace in a Desktop project in VS2017?

Question: Where in Windows 10 we can find Windows.Management.Deployment.dll or how can we install it?
In a WinForm project in VS2017 - ver 15.9.6 I'm trying to follow C# example of PackageManager.FindUsers(String) method that uses classes from Windows.Management.Deployment namespace.
But can't seem to find the location of above dll that is needed to add a reference in VS2017 project. I installed UwpDestop NuGet package, also add a reference to windows.winmd file, but that did not help either. I'm using Windows 10 Pro- Update 1809.
In your Winforms project you need to go to "Add Reference …" and hit the "Browse" button. Then navigate here and select the Windows.winmd file that corresponds to the Windows SDK you are targeting. Be sure to change the file extension filter to .

Deployment of Visual Studio solution containing dll project and exe project

I have a Visual Studio 2010 solution that contains 3 projects: a dll project, an executable project, and the Installer project.
I am working on the dll and the executable concurrently. The executable is simply a front end for the library. While developing the two in Visual Studio I simply added a reference to the dll project from within the executable and it works fine.
What I'm having trouble with is the deployment. Ideally the dll would be compiled and installed in a subdirectory of the executable. Using the "Visual Studio Installer - Setup Wizard" project template for my installer doesn't seem to be giving me the options I need.
Am I going about this wrong by developing my backend and frontend in different projects? What steps should I take to deploy the compiled dll along with the executable? I may be going about this all wrong, so please help me understand a better methodology if this seems backwards. For all the programming I learned in college, no one ever went over what I do when I actually want to deploy my software.
Since the DLL project is explicitly referenced from the EXE project, it is automatically copied in the EXE's build folder (i.e. bin\Debug or bin\Release) and is considered part of EXE project's "primary output". As a consequence, you only need to reference the EXE from your setup project.
The installed DLL will be in the same folder as EXE. Why would you want to install the DLL in a different folder on the user's machine if it is not there on the development machine? If you are loading it dynamically and using reflection, then don't reference it from EXE, but do reference it from the setup project, which then gives you the power to set whatever target folder you want.
This is what you need to do.
On your Solution create new Project > Other project Types > Click Setup and Deployment
On The Application Folder > right click > Then Add your front end Application > Build.
Check this
Regards

How can I include files in a C# deployment?

I have a DLL I need to deploy with my C# application. It's not currently included in the installation package when I hit "Publish" so how do I include it?
Would the process be any different if I had app.config and other files I wanted to deploy with my application?
If it's referenced it should be included automatically. I've deployed a couple of apps that require a 3rd party dll and they've published OK.
Is the dll referenced correctly in your project? That's the only thing I can think of at the moment that might be the problem, but if it wasn't your code wouldn't compile and/or link anyway.
To get the xls file to deploy all you need to do is add the file to the solution and then set the "Copy to Output Directory" property on the file.
I take it you are using Visual Studio?
If your using Visual Studio 2008 (I have no experience with Visual Studio 2005) under the Publish tab in your project properties click on the Application Files button. This will bring up a list of all dependencies assembalies required by your project. If you find that required dll is not being published by the Visual Studio publisher tool by default you can go into here and set the Publish Status of the offending dll to Include.
Sometimes in my more complicated projects, depending on the type of dependency, I have to go into this menu and force certain dll's to be included opposed to the default Prerequsite setting.
...but this is all under the assumption you have the assembly properly referenced in the required projects and everything is compiling fine.
Can't you add the dll as a resource to your installer project?

Categories