How to get access to XNA reference in windows form application - winforms

I am trying to get access to the Vector2 objects in a form application, but when I add the refence to XNA.Framework it says that it cannot be found. (But clearly the file exists) Any way to mitigate around this?

I had my build in AnyCPU, thus it was building in x64 natively. I simply right clicked the solution in Solution Explorer, went to Configuration Manager, and created a new build platform. (x86) Builds. :)

Related

Integrating a custom launcher into the Visual Studio Debugger

We're creating a Visual Studio Debugger extension that needs to launch the application being debugged through a custom launcher that sets up the runtime (not the CLR or Win32) and launch the target application in a new process. In other words, the custom launcher is in charge of creating the new process. In the VS Debugger, one typically launches the debugger by calling VsShellUtilities.LaunchDebugger() and supplying a VsDebugTargetInfo object whose dlo field is set to DEBUG_LAUNCH_OPERATION.DLO_CreateProcess, along with the coordinates of the exe file to be launched and debugged. This doesn't conform to our launching model.
There is also a dlo value DEBUG_LAUNCH_OPERATION.DLO_Custom that seems to be for this purpose (using the clsIdCustom field to indicate the launcher), but the current documentation says that's obsolete and directs us back to DEBUG_LAUNCH_OPERATION.DLO_CreateProcess, but not only doesn't that fit our model, but clsidCustom is used in this case to indicate the debug engine (if it's just a single one).
So, what is the recommended way for us to launch the VS debugger and use our custom launcher to configure and start our runtime (and the application within it)?
According to the Visual Studio API document, it only provide the DLO_CreateProcess to Launches the process. You could use dwClsidCount and pclsidList specify the debug engines to use.
Following example introduce how to call a custom launcher through a VSIX project.
https://code.msdn.microsoft.com/Visual-Studio-Debug-Engine-c2e21c0e
I'm having difficulty porting to a Modern VS2022 but I've been using the VSIX template built of of this Extension which works for VS2017 and VS2019. after some tinkering. This does work for VS2022 but only if you don't tamper with the packages.
https://github.com/microsoft/VSProjectSystem/blob/master/doc/extensibility/IDebugLaunchProvider.md Good luck there's not a lot out there so I thought I'd offer you this gem.
This allows you to make a drop done selection for a project property sheets for debugging. you got to import the targets file which then imports the rules sheet that you create which means you got to make a wizard that creates a custom project.

VS create winforms apps only with x86 configuration, why?

I have VS.NET 10.0.40219.1 SP1 in 2 computers and when I create a new C# Winform app only do it with Properties/Build/Platform x86, and the target let me choose AnyCpu/x64, but can't set it in the configuration (however, libraries work fine).
If I try to change it in the project file manually, I get a lot of nasty errors. Is this normal behavior, a bug or a problem in my installation?
P.D: When I change manually the project, this happend:
Warning 1 The OutputPath property is not set for project '*.csproj'.
Please check to make sure that you have specified a valid combination
of Configuration and Platform for this project. Configuration='Debug'
Platform='x86'. This error may also appear if some other project is
trying to follow a project-to-project reference to this project, this
project has been unloaded or is not included in the solution, and the
referencing project does not build using the same or an equivalent
Configuration or
Platform. c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets
When I reopen the project, ALL the references become invalid
It is normal for Visual Studio to create WinForms projects with just an x86 platform. I have no idea if that's because historically x86 was the only platform type or because x86 is the most commonly used value or for some other reason.
It's also normal to have problems when the project file is manually modified, try to avoid doing that where possible.
To create another platform configuration in a C# project
Select Build | Configuration manager
Select <New...> in the Active Solution Platform field
Select the new type you want
Click on OK
Visual Studio used to create AnyCPU apps by default. I think both VS2005 and VS2008 did this, though they may have changed it for VS2008. Here's what happened: a lot of AnyCPU apps ended up broken on 64-bit systems, because they were built with dependencies on 32-bit libraries. If you tried to run an AnyCPU app that had a 32bit dependancy on a 64bit system, you got a 64bit process that would crash as soon as it tried to load your 32bit dll.
To fix this, the default was changed to use the x86 option. If you want to use AnyCPU, you must now setup the environment for it.

.NET 4.0 XBAP security issues with GAC

We have a problem since converting our products to .NET 4.0 and using the updated code access security model. Basically we have component libraries that may or may not be installed to the GAC on a machine.
If someone makes an XBAP with default partial trust settings that uses these libraries and an end user installs the XBAP (which deploys the libraries during its install), it works fine if our libraries weren't already in the GAC.
If they were in the GAC, the XBAP will fail at run-time with security exceptions. I believe the problem is due to this:
http://msdn.microsoft.com/en-us/library/aa970906.aspx
When managed assemblies are installed into the global assembly cache (GAC), they become fully trusted because the user must provide explicit permission to install them. Because they are fully trusted, only fully trusted managed client applications can use them.
It seems that since they get pulled from the GAC, their security is elevated more even though they are the exact same .dlls deployed with the XBAP. But in that case, everything breaks.
Is there any way to work around this issue short of adding the AllowPartiallyTrustedCallersAttribute to all the libraries?
Or is there a way to prevent an XBAP from looking in the GAC for an assembly and just using the exact copy of the reference it is deployed with?
Thanks in advance for any assistance.
In visual studio, solution explorer, click on the reference and try setting the property "SpecificVersion" to true. It should just look in the path specified and the version specified when referencing and not go hunting for the latest in the GAC.
See .net reference specificversion true or false?
Note that if you add a new version of your reference, you'll have to remove your current reference, it won't automatically replace it.

How can I determine an application's software prerequisites?

I'm developing a small WinForms program for home use - I have no intentions to releasing it anywhere.
Running it on my development machine, where I have Visual Studio and .NET and whatever else installed, works but deploying it on my PC, where I might not have all those frameworks, doesn't. I'm using some library written in C++ so I'm assuming I'm going to need some version of Visual C++ Redistributable, but I'm not sure which? And I'm not sure if that would be all. So, how can I determine an application's software prerequisites?
I used Dependency Walker and I got a message IEHIMS.DLL - Error opening file. The system cannot find the file specified (2), but that's all I could make out; there is so much information I'm having trouble make sense of it all. Besides, according to a quick google, IESHIMS.DLL has something to do with Internet Explorer, so it shouldn't really matter.
Thanks in advance to anyone taking to the time to consider my question.
Kind regards
For framework you can set the prerequisites for your application by going to project properties -> Publish -> Prerequisites. So now, if the required framework is not installed on the deployment machine, the setup will prompt for an install.
Now, for other dlls you are using, copy those dlls to your bin folder of the project and add the files while creating setup. This will solve the problem.

Debugging silverlight application problem

My VS2010 doesn't stop at breakpoints inside of silverlight application. It appears that no symbols for it have been loaded during debugging. When I hover over the break point it says "The braekpoint will not currently be hit, no symbols have been loaded".
I have tried all of possible solutions offered by google and have no success. The problem occurs even when I create brand new silverlight app hosted by an ASP .NET web project. All of my project configuration looks fine - silverlight debugging is enabled in the Web project.
I am using silverlight 4.
here a link to the sample project created out from the tepmlate.
Any thoughts ?
P.S I just tried to reinstall VS2010 and the problem still exists.
EDIT: I just tested the same project on another machine and it stops at the break point it seams that the problem is somewhere in the configuration of VS or silverlight.
with Matt Dotson's help I managed to attach the debugger manually. However this solution is not good enough for daily use.
Depending on my experience in Silverlight following these steps keep your project debug-gable.
Condition 1>
Firstly we need to be ensure that in Web Project's properties there is a Web section, as you see below Silverlight checkbox must be checked.
Condition 2>
Follow In Menu Debug => Attach Debugger>
Visual Studio sometimes can't attach debugging platform you need to lead the way :) . By this way you may debug other platforms,(also you may debug your product platform but pdb files must be sync and don't forget you may suspend your product platform using this).
Condition 3> Your default web browser may be Firefox,Chrome or other than IE.By Visual Studio default try to attach to IE. But when you run VS calls default browser,so you need to have a manual attachment in Condition 2 or set your default browser by right clicking on default page > Browse with .
Condition 4> There is xap file generally located in web project\ClientBin directory. Sometimes after build operations this file can't be replaced and your ProjectDll and your Project PDB files not be sync. This cause wrong line match while debugging or can't find a debugging file attached caution. I strongly suggest delete all generated files in Bus project and delete Clientbin\ProjectName.xap file. After rebuild all it must be ok!
Hope helps.
What broswer are you using? You need to be using Internet Explorer to debug silverlight projects.
I have had a similar frustrating experience with this but in my case the solution was very simple. It seems that somehow, and I really have no idea how, the debugger option for Silverlight had become unchecked in the properties on the hosting ASP.NET project.
I just assumed that as I had been previously debugging, this option was set and I didn't bother to make sure that this was this case. Just goes to show that one should always check the basics first; if I had done that it would have saved me some time.
To check this in VS2010, right-click on the project and select properties, change to the Web tab and check the Silverlight option at the bottom of the page, in the debuggers section.
Also see the debugger to a silverlight process
http://msdn.microsoft.com/en-us/library/cc838267(VS.95).aspx
If that doesn't work, then
reset iis (if you are debugging in that)
delete temporary asp.net files (%SystemRoot%\Microsoft.NET\Framework\versionNumber\Temporary ASP.NET Files)
clean and rebuild your solution
The resolution came after 2 days of headbanging. It appears that the link which Malcolm gave covers exactly my problem but my I was narrow-minded enough not to pay it enough attention because when I run the debugger as long with the app my default browser was FF. So I thought that after the FF starts I can load the page from IE or Chrome.
Actually the problem is that the debugger cannot be attached to the silverlight project because of the FF. And when I load the app from IE or Chrome the debugger dis still not attached.
Thanks to everyone that tried to help.
if you have multiple project, Rebuild the project separately that you want break point. Its work for me
Try also picking internet explorer from browser list menu as your browser

Resources