I have a Win Forms application that I work on in either on my laptop or desktop. (Nothing special about the software, what i working on seems irrelevent)
Both displays on the desktop and laptop have different text scaling options.
On one computer the project layout (position of text boxes, labels etc) is fine, BUT! If you open the project on the other, everything moves and the layout ( / my GUI) ends up completely ruined. If you build / save this project, then all is lost and it all has to be reset/relocated to suit the computer your are building it on. Once the project is actually built, the application runs / looks fine. (on any screen/ res/ dpi scale) (EDIT: The built version is fine if it was built with the layout correct)
It seems that VS's designer cant handle the DPI scale change when working on the forms.
Does anyone know of a solution to this? I have changed the DPI scaling mode on several controls/forms and nothing seems to work. Its this just a Visual Studio Bug???
Thanks interwebs.
EDIT: OK Here is a twist: If you open the project with your screen text scaling set the same as the computer you last saved the project on, THEN (with VS open) change the text scaling, the controls move correctly and everything looks fine. (Stuff is where it should be) ......
You may have solved this problem by now, but ... Have you tried creating an external manifest file for Visual Studio?
Process is described here: http://www.danantonielli.com/adobe-app-scaling-on-high-dpi-displays-fix/ I copied Antonielli's photoshop manifest file exactly and it seems to work fine, which does not mean I understand it. I will show it below in case someone with knowledge can correct any errors.
Just tried this now, but it seems to be working for me. I am moving windows form app dev from a 1920x1080 laptop to a 2560x1440 laptop and my app scales fine when it runs, but VS2015 screens are unreadable. So, what you see in design is a mess and NOT what you get when you run the app.
My app simply sets AUTOSCALEMODE to INHERIT on all forms and then sets AUTOSCALEMODE to FONT on main form. Various posts here discuss better methods I am sure (e.g, Creating a DPI-Aware Application and How to control the font DPI in .NET WinForms app).
Here is Antonielli's photoshop manifest file (must change registry first per his blog link above) which is saved on my computer as "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe.manifest":
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.VC90.CRT"
version="9.0.21022.8"
processorArchitecture="amd64"
publicKeyToken="1fc8b3b9a1e18e3b">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</ms_windowsSettings:dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
Related
For my Project at work i want to install a provisioning Package, that contains a xml configuration for Kiosk Mode (Assigned Access).
I used the exact code from the xml reference page and inserted my Apps, as an account i used a local account that i created for testing.
<?xml version="1.0" encoding="utf-8" ?>
<AssignedAccessConfiguration
xmlns="http://schemas.microsoft.com/AssignedAccess/2017/config"
xmlns:rs5="http://schemas.microsoft.com/AssignedAccess/201810/config"
>
<Profiles>
<Profile Id="{786df454-09d0-492f-9ef0-c07731d1606f}">
<AllAppsList>
<AllowedApps>
<App DesktopAppPath="C:\Program Files\Google\Chrome\Application\chrome.exe"/>
</AllowedApps>
</AllAppsList>
<StartLayout>
<![CDATA[<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6">
<start:Group Name="Group1">
<start:Tile Size="4x4" Column="0" Row="0" DesktopAppPath="C:\Program Files\Google\Chrome\Application\chrome.exe" />
</start:Group>
</defaultlayout:StartLayout>
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
]]>
</StartLayout>
<Taskbar ShowTaskbar="true"/>
<Taskbar/>
</Profile>
</Profiles>
<Configs>
<Config>
<Account>.\Kiosk-test</Account>
<DefaultProfile Id="{786df454-09d0-492f-9ef0-c07731d1606f}"/>
</Config>
</Configs>
</AssignedAccessConfiguration>
When i try to install it, it either wont install at all with Error code 0x8007000b on one computer or on my private computer the installation will fail.
The Settings say that i has to Lock the user interface and make changes to the device.
then the EventLogs say that it failed due to follwing error: "Error during verification because the document does not contain exactly one root node. (0xC00CE223)" (translated with deepl, so might be a bit different in reality)
I could not find a matching solution on the internet.
I also tried using the configuration Wizard for single app Kiosk, and there the same error occured.
Does anyone of you know a solution to that or can tell me what the problem is at all?
I tried to change every part of the code, so that every aspect (App, User, e.g.) is tested seperately.
I moved my computer out the group policies, so that there are no GPOs that vreate an error.
The error messages didn't change at all
Thanks and best Regards!
Is there a way to compile a WPF application twice in Visual Studio (version 2015/2017) with different manifest files?
On the one hand I need the application to require administrator permissions, on the other hand the same application without administrator permissions (means: without or another manifest file).
With compile constants I'm able to do something like this:
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="Update.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
#if ADMIN
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
#endif
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
but this doesn't seem to work like expected.
A solution where I only need to click the build button once and receive two applications would be perfect.
Another possible solution is to use post-build commands, but I'm not sure if this will work.
There is an option in Visual Studio 2017 (and maybe earlier versions, I cannot confirm) that allows you to build multiple configurations in a single run.
Look at the toolbar menu: "Build" > "Batch Build"
I'm working on a ClickOnce app that's set to online-only. I publish it to an internal IIS server, with an HTML page in the same directory that contains this link:
The deployment looks like so, with all files except the HTML page generated by my project's publish target:
MyAppName
-> Application Files
-> MyAppName_2213_20_0_65
-> <The published files>
-> default.html
-> MyAppName.application
When I click the link, the app runs immediately without any confirmation prompt, and I see from the about box that it's the old version. When I browse to the file share and launch MyAppName.application by double-clicking on it in Explorer, I get the prompt asking me if I'd like to run it, and then it downloads and I get an error:
Unable to install this application because an application with the same identity is already installed. To install this application, either modify the manifest version for this application or uninstall the preexisting application.
As part of the build process, I set the InstallUrl property of the project to http://ourserver/MyAppName/MyAppName.application. Is that wrong? Should it be the HTML page that contains the link? How is it determining the "identity" that's generating a conflict?
Since the app's online-only, it's not installed and doesn't show up in the Programs and Features control panel (and therefore that part of the error message doesn't apply).
I'm new to ClickOnce, so let me know if I left out some helpful information.
Update
If I run mage -cc from a Visual Studio command prompt, the new version launches instead of the old one.
Update 2
As I poked around more, I'm seeing something that looks wrong, and could be the problem. I see the following two lines in my MyAppName.application file (the deployment manifest):
...
<assemblyIdentity name="MyAppName" version="1.0.0.0" ...
...
<dependency>
<dependentAssembly dependencyType="install" codebase="Application Files\MyAppName_2213_20_0_65\MyAppName.exe.manifest" size="82044">
<assemblyIdentity name="MyAppName.exe" version="1.0.0.0" ...
...
You can see the mismatch above. It's deploying to MyAppName_2213_20_0_65, but it thinks the version number of the exe is 1.0.0.0. I'm not sure why it thinks that. My project includes a file that gets generated as part of the build with this line:
[assembly: AssemblyVersion("2213.20.0.65")]
Then, to set the published version number, I have this in my csproj file:
<Target Name="BeforePublish">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="MyAppAssemblyInfo" />
</GetAssemblyIdentity>
<PropertyGroup>
<ApplicationVersion>%(MyAppAssemblyInfo.Version)</ApplicationVersion>
<InstallUrl>$(INSTALL_URL)</InstallUrl>
</PropertyGroup>
</Target>
Does the assembly version listed for my executable even matter? If it does, why is it stuck on 1.0.0.0, and could that be affecting the download of updated versions?
My second update put me on the right track. The problem was indeed the incorrect version number for the assemblyIdentity attributes. To fix it, I'm no longer using a BeforePublish target. Instead, I'm passing in the ApplicationVersion when I call MSBuild:
"%msbuild_path%" MyAppName.csproj /target:Publish /p:ApplicationVersion=%VERSION%
I keep having a problem running multiple versions of the same solution. I am working on a new release of our Silverlight product, and it's located in a dev branch. Meanwhile I have to fix an issue in the deployed version, located in our maintenance branch.
Whenever I start up a VS (2013) instance of the maintenance version, my dev branch suddenly starts running the maintenance version instead. At least that's what I think is happening, because the UI looks like the maintenance version, and any breakpoint will say that the source file differs from the version built. The only way to get my dev version working again, is to close both VS instances, and open the dev version alone.
Does anyone have a clue what's going on? I have tried a lot of other things as well, but the only thing working is closing both VS instances:
Checked the build configuration
Checked that Silverlight debugging is enabled
Deleted bin/obj folders
Updated the Default.apsx file with so browser cache should be ruled out
UPDATE:
Ok, I found the reason, but not the fix. The project is configured to use IIS express and port 7751:
When I check the applicationhost.config, I found the entry, and it looks something like this:
<site name="ProjectName" id="23">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="xxxxxxxx\dev-branch\project" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:7751:localhost" />
</bindings>
</site>
But I start up the maintenance version of the same solution, the virtual directory immediately changes path to the maintenance version instead (without running the project):
<site name="ProjectName" id="23">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="xxxxxxxx\maintenance-branch\project" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:7751:localhost" />
</bindings>
</site>
So now my question is - how do I ensure that it is possible to run multiple version of the same solution side-by-side?
You should configure the project to run on different ports.
I have a WPF app that creates some text files in its own install directory. However, even after the UAC prompt, windows vista and windows 7 users often times still get "file access failed" type errors. The solution is to find the executable in windows explorer and open up the compatibility tab under the file properties and check "run as administrator". This is obviously a terrible user experience but I'm not sure how to ensure the app can secure itself these permissions without that step being taken. I am not trying to bypass the UAC prompts.
In general, .Net wants you to put application generated files either into the user's home directory or the shared user folder. Have a look at this answer: When using a Settings.settings file in .NET, where is the config actually stored?
It talks about .Net config files but you can put other files there.
You can force your app to start with admin rights (UAC will show it's dialog box anyway) by embedding custom manifest (project properties -> build -> Manifest).
Manifest example (requestedExecutionLevel part is importaint):
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0"
xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="yourappname.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with. Windows will automatically select the most compatible environment.-->
<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
</application>
</compatibility>
</asmv1:assembly>