I'm writing a program with C# on Visual Studio 2012. I have encountered the following problem.
The first, I configure the assembly name on project C# is "ABC", I built and it generated the executive file is "ABC.exe", then when run this exe on the PC (Windows 8), the Task Manager displays process name is "ABC" => It's ok!
And then, I changed assembly name to "CDE", rebuild and it generate file "CDE.exe".
And when run "CDE.exe" file on above Window 8 PC, the Task Manager displays process name still is "ABC"?
Note that this problem occurs only on the PC run Windows 8. I tested on 2 PC run Windows 7, the process name will update is "CDE.exe".
Someone can tell me what happen?
Windows is picking up the value of the AssemblyTitleAttribute specified for your executable assembly.
Open up AssemblyInfo.cs, and you should find this line:
[assembly: AssemblyTitle("ABC")]
Change that (and any other attributes in the same file) accordingly.
Related
lately I have encountered a following problem. Azure Function that is run in Visual Studio always throws an exception:
System.IO.IOException HResult=0x80131620 Message=Error loading
native library
"C:\Users\\AppData\Local\AzureFunctionsTools\Releases\2.16.0\cli\grpc_csharp_ext.x86.dll"
Source=Grpc.Core StackTrace: at
Grpc.Core.Internal.UnmanagedLibrary..ctor(String[]
libraryPathAlternatives) at
Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary() at
Grpc.Core.Internal.NativeExtension.LoadNativeMethods() at
Grpc.Core.Internal.NativeExtension..ctor() at
Grpc.Core.Internal.NativeExtension.Get() at
Grpc.Core.GrpcEnvironment.GrpcNativeInit() at
Grpc.Core.GrpcEnvironment..ctor() at
Grpc.Core.GrpcEnvironment.AddRef() at
Grpc.Core.Server..ctor(IEnumerable`1 options) at
Microsoft.Azure.WebJobs.Script.Grpc.GrpcServer..ctor(FunctionRpcBase
serviceImpl) in
C:\azure-webjobs-sdk-script\src\WebJobs.Script.Grpc\Server\GrpcServer.cs:line
24
The file that is supposedly missing is at its place of course. I've tried to reinstall Azure Function Tools and Visual Studio and nothing helped. Any ideas?
Thanks in advance.
EDIT1:
The problem seems to be caused by non-english characters in the path to the library. I've just created another account without them and suddenly everything started to work.
from the point that the root cause of error is because of the non-english characters in the path to the library, you can consider to rename path of your user profile.
To do so, here is the steps
Log out and login with another Administrator user to your PC
open command prompt by CTRL + R then type cmd
type wmic useraccount get name, sid and get SID of your profile
type regedit under start menu, right click on it and select Run as Administrator
Go under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\YOUR_SID_HERE
Double Click on ProfileImagePath and change the value data according to your need (you can close Registry Editor)
go under USER PROFILES folder (%USERPROFILE%\..\) and change the path of your user profile accordingly
Restart your computer
I faced very strange behaviour - after I overwrite .NET exectables with new versions from network drive it cannot start.
When try to start from Windows Explorer it shows me following error:
[Window Title]
C:\Programs\zzz\clients.net\zzzNet.exe
[Content]
C:\Programs\zzz\clients.net\zzzNet.exe
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
I tried to execute following commands:
SxsTrace Trace -logfile:SxsTrace.etl
SxStrace Parse -logfile:SxSTrace.etl -outfile:SxSTrace.txt
And got following result:
=================
Begin Activation Context Generation.
Input Parameter:
Flags = 0
ProcessorArchitecture = AMD64
CultureFallBacks = en-US;en;ru-RU;ru
ManifestPath = C:\Programs\zzz\clients.net\zzzNet.exe
AssemblyDirectory = C:\Programs\zzz\clients.net\
Application Config File = C:\Programs\zzz\clients.net\zzzNet.exe.Config
-----------------
INFO: Parsing Application Config File C:\Programs\zzz\clients.net\zzzNet.exe.Config.
INFO: Parsing Manifest File C:\Programs\zzz\clients.net\zzzNet.exe.
INFO: Manifest Definition Identity is (null).
ERROR: Line 0: XML Syntax error.
ERROR: Activation Context generation failed.
End Activation Context Generation.
It is quite simple .NET application (1 exe + 8 dll files). It was built for .NET 3.5 Client Profile.
I not defined any special "manifest" there. Just clicked "New Windows Forms Project" in Visual Studio and developed it.
Also app.config does not contain anything special - only primitive standard settings - appSettings and userSettings sections.
On PC where I developed it all is perfectly works. Problems only began when I copy these binaries to this particular VM and try to start.
Also please note - these executables were not installed in GAC or such, I just copied them into a folder on VM and started. And when it was 1st time all was working fine.
So, the problem pattern is following:
Copy .NET execuatbles to new VM (it is Win 7 x64), run it, all is working fine. Close it.
Build new version of .NET execuatbles on host PC, copy new .NET execuatbles to VM (with files overwriting).
Try to start - got mentioned problem.
After some shaman-style actions (like OS reboot, etc) it begin to work but why that happened at all?!
Why replacing .NET executables with new versions is causing SUCH HUGE PROBLEMS?!
Also the BIG QUESTION - is there any special procedure to replace .NET executables to keep them working? Because it is a new app development, I do not want lost so much time on every new executables installation. :-\
Could you please help? Because it looks completely weird!
Thank you in adance.
PS. I checked all VS projects - all they have PlatformTarget=AnyCPU. Also in run-time I can see ProcessType=MSIL (I show this info in AboutBox for application). So, there is no mix of x86/x64 binaries.
It seems that was related to mapped network drive behavior.
When I copied new files from network drive folder it copied wrong files - a strange random mess of new files and older ones (which were there before I updated them on VM host).
The scenario to make it working:
on VM: delete all files in a folder on network drive
on VM host: copy new files into a folder which is mapped as network drive on VM
on VM: copy files into target folder
on VM: run application - it works now
Weird thing. I remember I have seen something similar with Windows Explorer on Windows 2008 behaviour when copying updated win32 binaries.
I'm trying to add a subdirectory to an existing path.
Win-7 64, Intel SSD
Logged into company domain as a user with admin priv, but not as "Administrator"
Visual Studio 2008, launched normally (not "Run as Admin")
Here's MyApp (WinForms, Debug, x86):
[STAThread]
private static void Main(string[] args)
{
string p = #"C:\ProgramData\MyCompany\MyApp";
Directory.CreateDirectory(p);
string f = "a.txt";
string fullPath = Path.Combine(p, f);
File.WriteAllText(fullPath, string.Empty);
Directory.Delete(p);
As expected, the last line throws IOException: "The directory is not empty". Should mean the subdir and file got created.
Problem: Windows Explorer does not show the MyApp subdir (even after refresh, type path in address bar, close/reopen, or reboot).
C:\ProgramData\MyCompany\ was created by another application's installer; Windows Explorer says its current owner is System.
Used same IDE to create a console app (Debug, x86), copied the above lines and ran; Windows Explorer was happy to show me DigitalTestApps and the file inside.
If I do any one of the following to MyApp, the problem goes away (i.e. Windows Explorer shows me the "MyApp" subdir and the file inside):
Build as x64
Launch Visual Studio using "Run as Admin"
Use any name other than "MyApp" (but I need to use MyApp for legacy reasons)
What could be causing this?
#dtb was too humble (or busy) to repost his comment (which solved my problem) as an answer, so I'll copy his comments here to make it easier for others to see how this turned out:
"Check if you can find your directory & file somewhere in C:\Users\JimC\AppData (Folder virtualization).
related: Why Virtualization on ProgramData folder in MS Vista?"
So here is what I did after reading his advice:
I deleted the virutalized directory from under C:\Users and it started working fine. Not sure how it got created in the first place, but seemingly, while it exists, attempts to create the directory where I was expecting it finds the virtualized one instead.
Thanks again dtb.
This question was originally posted as "Error occurred loading a configuration file: Access to path c:\Program Files (x86)\… denied", but I didn't have much success finding a solution.
My application was written on Windows 7, it's a 32-bit application written with Visual Studio 2010. When I try to deploy this application on a Windows 8 system, the app fails during form_Load, with an error about access to a tmp file in the EXE's directory. I am not creating this temp file directly, but it has a name which is consistent with one generated by the C# GetTempFileName method. The name of the EXE config file (MyApp.exe.config) is also referenced in the error message.
I use the ConfigurationManager to store all of my application settings at startup, so I'm guessing that it is somehow related to this. If I build the application on a Windows 8 system it runs fine on the Windows 8 system, but generates the same error if deployed on a Windows 7 system. I don't know yet exactly what line of code is causing the error but the calls boil down to
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add(settingName, settingValue);
config.Save();
ConfigurationManager.RefreshSection("appSettings");
Both the Windows 7 and 8 systems are 64-bit but the application is 32-bit. Thanks in advance for any advice in solving this.
I use the Settings class to handle the configuration data and the TEMP variable is what I expect it to be, my user\AppSettings\Local\Temp.
The problems encountered were on an evaluation version of Windows 8, this was all that was available. Running the application on a licensed version of Windows 8 Pro it works perfectly.
Thanks for the replies.
I have created a very simple window service using visual studio 2010 and .NُET 4.0.
This service has no functionality added from the default windows service project, other than an installer has been added.
If I run "installutil.exe appName.exe" on my dev box or other windows 2008 R2 machines in our domain the windows service installs without issue.
When I try to do this same thing on our customer site, it fails to install with the following error.
Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Exception occurred while initializing the installation:
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\TestService\WindowsService1.exe' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515).
This solution has only 1 project and no dependencies added.
I have tried it on multiple machines in our environment and two in our customers. The machines are all windows 2008 R2, both fresh installs. One machine has just .net 2.0 and .net 4.0. The other .net 2, 3, 3.5 and 4.
I am a local admin on each of the machines.
I have also tried the 64bit installer but get the following error, so I think the 32 bit one is the one to use.
System.BadImageFormatException
Any guidance would be appreciated. Thanks.
Another reason for this error might be that you copied your program from a source which windows considers untrusted.
You can unblock the assembly by clicking "unblock" after you right-click and select properties on the file.
Need to unblock files. or at least that's what fixed mine.
To do 'bulk' unblock in Powershell
get-childitem *.* | Unblock-File
or in DOS:
FOR %a in (*.*) do (echo.>%a:Zone.Identifier)
When we copy executable from another computer, Windows mark a flag on them for protection. Right Click on executable and in properties Click Unblock. It would clear flag and service executable would Install.
This issue came about for me because I was trying to install the service from a network location. By copying the service.exe to the local machine prior to using installutil, it fixed my problem and the service installed successfully.
don't forget to vote up...
Try the SC as follows:
1. open command line
2. write the below-
sc create ServiceName BinPath= "ExePath".
report on results...
I also faced the same issue. In my case I was deploying new version of utilities , i copied new exe , installog files and then trying to uninstall the utils.
I copied back the old version , uninstal the utils , copied the new version and installed it again. Anyway it is the logical sequence I should have followed in first place.
i have this issue and it for different between of .net version of util and my service
i use util for .net 2 and my service build with .net4
In my case this error was caused by accidentally passing the directory containing the service to InstallUtil instead of passing the service exe.
Obviously human error but I found the error message quite misleading.
you can use this command in developer command prompt run administrator
installutil C:\...\MyService\bin\Debug\MyService.exe
As per #doublehelix's response above, this answer put me on track for my particular issue which related to a service issue running in Windows XP (Unblock is not an option in the security tab that I could find). In my case I was attempting to run a service from a separate drive (i.e. not on the same drive as Windows and not under program files) although the actual physical disk was the same. Moving my service into the Program Files folder solved my underlying issue. (I intended to 'comment' against #doublehelix's answer but I don't seem to be able to in my current status).
Simply right click on your service files and select properties and then check the unblock checkbox
https://brianseekford.azurewebsites.net/2011/07/13/hresult-0x80131515-when-running-installutil-to-install-a-net-service/
Unblocking files did the job here. Weird thing is that the blocked files came from a signed installer run with admin privileges. Had to unblock several files in several folders at once.
I used the following registry tweaks to add context menus to a folder or file when Shift + right-click is pressed (it doesn't show up if just right-clicked).
Credits and references to the author in each code block.
Folder tweak:
Just save it as ShiftUnblockFolder.reg and import into Registry.
Windows Registry Editor Version 5.00
; Created by: Shawn Brink
; Created on: March 17th 2019
; Tutorial: https://www.tenforums.com/tutorials/129101-add-unblock-file-context-menu-windows-10-a.html
[HKCR\Directory\shell\unblock]
"MUIVerb"="Unblock"
"Extended"=""
"SubCommands"=""
[HKCR\Directory\shell\unblock\shell\001flyout]
"MUIVerb"="Unblock files only in this folder"
[HKCR\Directory\shell\unblock\shell\001flyout\command]
#="powershell.exe get-childitem -LiteralPath '%L' | Unblock-File"
[HKCR\Directory\shell\unblock\shell\002flyout]
"MUIVerb"="Unblock files in this folder and subfolders"
[HKCR\Directory\shell\unblock\shell\002flyout\command]
#="powershell.exe get-childitem -LiteralPath '%L' -recurse | Unblock-File"
Single file tweak:
ShiftUnblockFile.reg
Windows Registry Editor Version 5.00
; Created by: Shawn Brink
; Created on: March 17th 2019
; Tutorial: https://www.tenforums.com/tutorials/129101-add-unblock-file-context-menu-windows-10-a.html
[HKCR\*\shell\unblock]
"MUIVerb"="Unblock"
"Extended"=""
[HKCR\*\shell\unblock\command]
#="powershell.exe Unblock-File -LiteralPath '%L'"
[HKCR\Directory\shell\unblock]
"MUIVerb"="Unblock"
"Extended"=""
"SubCommands"=""
[HKCR\Directory\shell\unblock\shell\001flyout]
"MUIVerb"="Unblock files only in this folder"
[HKCR\Directory\shell\unblock\shell\001flyout\command]
#="powershell.exe get-childitem -LiteralPath '%L' | Unblock-File"
[HKCR\Directory\shell\unblock\shell\002flyout]
"MUIVerb"="Unblock files in this folder and subfolders"
[HKCR\Directory\shell\unblock\shell\002flyout\command]
#="powershell.exe get-childitem -LiteralPath '%L' -recurse | Unblock-File"
You can try to make a Setup Project for your service and run the MSI file on that server.