My aim is to be able to use any packer for C# applications and libraries (preferring WPF) via command line or full build-in at Visual Studio.
I came accross .NetZ (http://madebits.com/netz/) that is pretty neat and worked pretty well until I tested it with a WPF application:
PackageExample.Program -> C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\PackageExample.Program.exe
COMMAND: packcompress\netz-bin-40\netz.exe -o PackageExample.Program\bin\Debug\Packed -pl
anycpu -s -z PackageExample.Program\bin\Debug\PackageExample.Program.exe
"PackageExample.Program\bin\Debug\*.dll" -d:# -v
__________________________________________
| |
| .NETZ - .NET Executables Compressor |
| Copyright (C) 2004-2013 Vasian Cepa |
| [v0.4.8] http://madebits.com |
|__________________________________________|
PE subsystem : GUI
.NET Runtime : 4.0.30319.18052
Output directory: C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\Packed
RID: zip.dll
Added : C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\packcompress\netz-bin-40\zip.dll [65536 byte(s) ~ 64KB]
Processing : 3 file(s)
1| C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\PackageExample.Program.exe
[255488 byte(s) ~ 249KB] -> [130850 byte(s) ~ 127KB] - 49%
RID: A6C24BF5-3690-4982-887E-11E1B159B249
2| C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\PackageExample.Lib1.dll
[4096 byte(s) ~ 4KB] -> [1577 byte(s) ~ 1KB] - 62%
RID: PackageExample.Lib1!2!1Version=1.0.0.0!2!1!4=neutral!2!1PublicKeyToken=null
3| C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\PackageExample.Lib2.dll
[4608 byte(s) ~ 4KB] -> [1617 byte(s) ~ 1KB] - 65%
RID: PackageExample.Lib2!2!1Version=1.0.0.0!2!1!4=neutral!2!1PublicKeyToken=null
Done [00:00:00.300]
The packed app throws this: http://i.imagebanana.com/img/251ygj82/Unbenannt.PNG
(The ressource mainwindow.xaml cannot be found.)
The problem seems to be the xaml .NetZ confuses, but I found some people who got it working on the internet, but I do not get any problem solution.
Are you able to help me in this case?
Additional information: It might be interesting to mention I even tried this with the .NET 2.0 .NetZ build on a .NET 3.5 WPF application.
I also had problems using NetZ to compress an WPF 4.0 exe and DLLs into a single exe.
My app.xml.cs would start to run, but then an UnhandledException of type NotImplementedException would be thrown:
Baml2006SchemaContext.ResolveBamlType ...
To troubleshoot this, I ran fuslogvw.exe to see assembly binding errors, and discovered that GalaSoft.MvvmLight.Wpf4.dll was failing to load from the Netz-packed assembly.
I then switched to NetZ.exe compiled from source and tried again.
After repeated experimentation, I see that if I recompile and NetZ-pack the app, it sometimes starts working. Recompile again the main app again, and NetZ produces a failing app.
In other words, something is intermittent.
Sorry for the not-so good news - either try another packing scheme, or try NetZ repeatedly on many builds, until you find a working one.
Related
I am using Linux containers on the latest Windows build Windows 10 2004 and enabled WSL 2 and Docker Desktop 2.3.0.3 (45519).
I right click the docker-compose file, and select Set as Startup Project.
I then hit F5 to debug.
I can see the image running with docker ps however breakpoints are not being hit.
I cannot view Logs (on the Visual Studio Containers window) as it says:
It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found.
- No frameworks were found.
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=debian.10-x64
I have installed the SDKs from the link given above.
Build output is below:
1>------ Build started: Project: Libertas.Host.Tickers.ScheduledTasks, Configuration: Debug Any CPU ------
1>Libertas.Host.Tickers.ScheduledTasks -> C:\Users\User\Source\Repos\myrepo\Libertas\src\Libertas.Host.Tickers.ScheduledTasks\bin\Debug\netcoreapp3.1\Libertas.Host.Tickers.ScheduledTasks.dll
1>docker build -f "C:\Users\User\Source\Repos\myrepo\Libertas\src\Libertas.Host.Tickers.ScheduledTasks\Dockerfile" --force-rm -t libertashosttickersscheduledtasks:dev --target base --label "com.microsoft.created-by=visual-studio" --label "com.microsoft.visual-studio.project-name=Libertas.Host.Tickers.ScheduledTasks" "C:\Users\User\Source\Repos\myrepo\Libertas\src"
1>Sending build context to Docker daemon 1.362MB
1>
1>Step 1/4 : FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
1> ---> 86a2e7d45948
1>Step 2/4 : WORKDIR /app
1> ---> Running in d1ed1740d43e
1>Removing intermediate container d1ed1740d43e
1> ---> 90bd1703e28d
1>Step 3/4 : LABEL com.microsoft.created-by=visual-studio
1> ---> Running in 2626d5865d89
1>Removing intermediate container 2626d5865d89
1> ---> da74703374d2
1>Step 4/4 : LABEL com.microsoft.visual-studio.project-name=Libertas.Host.Tickers.ScheduledTasks
1> ---> Running in 7a381e7ea47a
1>Removing intermediate container 7a381e7ea47a
1> ---> fd2dd439cce6
1>Successfully built fd2dd439cce6
1>Successfully tagged libertashosttickersscheduledtasks:dev
1>SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
1>docker rm -f 9ff95181e06801ed3d4b4d5743397604b743d77c840f2047fb2caee046e5d8eb
1>Error: No such container: 9ff95181e06801ed3d4b4d5743397604b743d77c840f2047fb2caee046e5d8eb
1>docker run -dt -v "C:\Users\User\vsdbg\vs2017u5:/remote_debugger:rw" -v "C:\Users\User\Source\Repos\myrepo\Libertas\src\Libertas.Host.Tickers.ScheduledTasks:/app" -v "C:\Users\User\Source\Repos\myrepo\Libertas\src:/src/" -v "C:\Users\User\AppData\Roaming\Microsoft\UserSecrets:/root/.microsoft/usersecrets:ro" -v "C:\Users\User\.nuget\packages\:/root/.nuget/fallbackpackages" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages" --name Libertas.Host.Tickers.ScheduledTasks_1 --entrypoint tail libertashosttickersscheduledtasks:dev -f /dev/null
1>ba95df9d32d6a0af07b1eab32af606131e075b2afff664c4003dbe3eae349543
========== Build: 1 succeeded, 0 failed, 6 up-to-date, 0 skipped ==========
My Dockerfile is below:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["Libertas.Host.Tickers.ScheduledTasks/Libertas.Host.Tickers.ScheduledTasks.csproj", "Libertas.Host.Tickers.ScheduledTasks/"]
COPY ["Libertas.Application.Tickers.ScheduledTasks/Libertas.Application.Tickers.ScheduledTasks.csproj", "Libertas.Application.Tickers.ScheduledTasks/"]
COPY ["PolygonIo.WebSocket/PolygonIo.WebSocket.csproj", "PolygonIo.WebSocket/"]
RUN dotnet restore "Libertas.Host.Tickers.ScheduledTasks/Libertas.Host.Tickers.ScheduledTasks.csproj"
COPY . .
WORKDIR "/src/Libertas.Host.Tickers.ScheduledTasks"
RUN dotnet build "Libertas.Host.Tickers.ScheduledTasks.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Libertas.Host.Tickers.ScheduledTasks.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Libertas.Host.Tickers.ScheduledTasks.dll"]
I am unable to hit any breakpoints or even confirm if the app is running. I have a Generic Host app, and I don't even hit the breakpoint of the first line within public static void Main(string[] args).
Pointers much appreciated.
UPDATE AND FIX
So this was the smoking gun, in particular as this was a console application, and not a AspNetCore app.
It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found.
- No frameworks were found.
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=debian.10-x64
I found one of my referenced libraries had a reference to Grpc.AspNetCore.
Once i moved this code out, it was able to run (I can confirm before the container instance was not running), with full debugging.
It compiled OK, the container ran, the application within the container never seemed to launch.
QUESTION
I would like to get to the bottom of why, as i don't fully understand how this fixed everything and what can be done to avoid in future (seems any console app that references a library that accidentally or otherwise references an AspNetCore dependency could have the same issue).
I had run into a similar problem... well, I think that the reasons are quite similar, in my case, I could not do anything, I could not even build the project, I had compiling errors, 'simple' ones... lol... let's say that using system; was erring and some other libraries that are there by default.
After a lot of investigation, I found out that my project was in net standard 2.0, but one of the nuget packages was for net standard 2.1, removing that package and finding a way to fix that part of the code resolved the problem.
The reason I believe was similar to what you are after, when adding the libraries, you are adding external code, external code that you don't control, so if the external library was referencing to another library that was not compatible with your project, like in my case, so I believe that the libraries were fighting to decide if it was meant to be a console or a web server app, have you tried to see the process that was created?
I also had a look at the library that you are mentioning (https://www.nuget.org/packages/Grpc.AspNetCore) and then click on dependencies and then there is this package:
Grpc.AspNetCore.Server.ClientFactory
which may have caused the crash.
Be careful with nuget packages, they are pretty cool and 'useful' but look at the dependencies, sometimes it is better to do your own code, that was my lesson.
For more details : https://learn.microsoft.com/en-us/dotnet/standard/library-guidance/dependencies
QUESTION I would like to get to the bottom of why, as i don't fully understand how this fixed everything and what can be done to avoid in future (seems any console app that references a library that accidentally or otherwise references an AspNetCore dependency could have the same issue).
In Visual Studio Solution Explorer shows us the dependency tree with Nuget Packages and above that is the Frameworks listing Microsoft.NETCore.App:
This is how we can see the GitHub Repo references AspNetCore:
<FrameworkReference Include="Microsoft.AspNetCore.App" />
How can I stop this from happening?
Check Solution Explorer for Frameworks.
Have Unit Tests on the config and dependencies.
Always review the Package Dependancies you import.
If you're looking for the canonical story it's over here.
The problem Iria discusses can be prevented with NuGet Version ranges and wildcards notation. When referring to package dependencies, NuGet supports using interval notation for specifying version ranges, summarized as follows:
+-----------+---------------+-------------------------------------------------------+
| Notation | Applied rule | Description |
+-----------+---------------+-------------------------------------------------------+
| 1.0 | x ≥ 1.0 | Minimum version, inclusive |
| (1.0,) | x > 1.0 | Minimum version, exclusive |
| [1.0] | x == 1.0 | Exact version match |
| (,1.0] | x ≤ 1.0 | Maximum version, inclusive |
| (,1.0) | x < 1.0 | Maximum version, exclusive |
| [1.0,2.0] | 1.0 ≤ x ≤ 2.0 | Exact range, inclusive |
| (1.0,2.0) | 1.0 < x < 2.0 | Exact range, exclusive |
| [1.0,2.0) | 1.0 ≤ x < 2.0 | Mixed inclusive minimum and exclusive maximum version |
| (1.0) | invalid | invalid |
+-----------+-------------
When you're adding Packages enforce a version, this way you keep track of your dependancies with different versions (and ultimately versions of the .net framework).
Change the BASE image to use aspnet instead of runtime. The runtime image does not contain the ASPNET libs.
🪲 runtime:3.1-buster-slim
to
👍 aspnet:3.1-buster-slim
This also works for newer releases of .NET.
I have a solution where my main project is a uwp app, and two other projects referenced by the app :
UWP App ---> references 2.
Universal Class library ----> references 3.
PCL Library
2 --> uses EF7 and SQLight.
3 --> uses PCLCrypto
Now, everything works just fine and excellent when I'm on Debug mode x86 targeting local machine.
I want to compile the solution in release mode using .Net native tool chain, here's my config :
When I launch the compilation, it takes a remarkably long time, and too much memory is consumed by the .Net native tools :
After some time, everything stops with 2 errors on visual studio :
Here's what the output window says :
1>------ Build started: Project: ServerCommunication, Configuration:
Release Any CPU ------ 1> ServerCommunication ->
C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\ServerCommunication\bin\Release\ServerCommunication.dll
2>------ Build started: Project: NewspaperDataLayer, Configuration:
Release x86 ------ 2>C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets(225,5):
warning : All projects referencing ServerCommunication.csproj must
install nuget package Microsoft.Bcl.Build. For more information, see
http://go.microsoft.com/fwlink/?LinkID=317569. 2> NewspaperDataLayer
-> C:\Users\aymen\Documents\Visual Studio 2015\Projects\Applinova\Liberte\NewspaperDataLayer\bin\x86\Release\NewspaperDataLayer.dll
3>------ Build started: Project: Liberte, Configuration: Release x86
--some warnings here that I just skipped
3> Starting .NET Native compilation 3> Processing application code
3>C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\Liberte\Resources.System.Linq.Expressions.rd.xml(35):
warning : Method 'CreateLambda' within
'System.Linq.Expressions.Expression' could not be found.
3>C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\Liberte\Resources.System.Linq.Expressions.rd.xml(91):
warning : Method 'ParameterIsAssignable' within
'System.Linq.Expressions.Expression' could not be found. 3> Computing
application closure and generating interop code 3> Generating
serialization code 3> Compiling interop code 3> Cleaning up
unreferenced code 3> Generating native code 3>STARTPROCESSTASK :
error : Out of Memory 3>C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x86\ilc\IlcInternals.targets(1129,5):
error : ILT0005: 'C:\Program Files
(x86)\MSBuild\Microsoft.NetNative\x86\ilc\Tools\nutc_driver.exe
#"C:\Users\aymen\Documents\Visual Studio
2015\Projects\Applinova\Liberte\Liberte\obj\x86\Release\ilc\intermediate\MDIL\Liberte.rsp"'
returned exit code 1
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
What would possibly be wrong with this please ??
I had the same problem (I am also using EF7 and other libraries) but I solved using Visual Studio 15 preview (it is not visual studio 2015 update 2, which I didn't try). They improved the .NET native tools so now you should not have any problem, even if using a lot of third party library.
UPDATE
I have solved all my issues after i have installed visual studio 2015 update 3 and switched from EF7 to EF core also available via nuget
I have been struggled past few days around trying to fix this problem, but currently there is no easy solution for it.
There is a closed Issue on EF7 github, more info here (https://github.com/aspnet/EntityFramework/issues/4387) where they suggest as solution update EF7 to v1.0.0-rc2-16898.
I didn't manage how to update and as it still a nightly version, my final solution ("fast" workaround) was change my entire DB to sqlite-pcl (https://visualstudiogallery.msdn.microsoft.com/4913e7d5-96c9-4dde-a1a1-69820d615936).
If you aren't in a rush to lunch your application, you can always wait until final version of RC2 it should be done during April.
I m trying to compile the latest Mono source from GIT (3.4.1) on the raspberry pi, i can make, and make install, but if i go to /usr/local/lib/mono i get only “2.0 compat-2.0 gac” folders and none for the other frameworks.
When i try to run:
pi#raspberrypi ~/testeMono $ mcs hello.cs
pi#raspberrypi ~/testeMono $ mono hello.exe
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/usr/local/lib/mono/4.5/mscorlib.dll' directory.
I have a initial mono installation that i got doing "sudo apt-get install mono-complete" (since i need mono to build mono) it's on /usr/lib/mono
i did 'make check' and here are the failed tests
420 test(s) passed. 6 test(s) did not pass.
Failed tests:
block_guard_restore_aligment_on_exit.exe
bug-10127.exe
finally_block_ending_in_dead_bb.exe
pinvoke2.exe
pinvoke3.exe
winx64structs.exe
make[5]: *** [runtest] Error 1
make[5]: Leaving directory `/home/pi/mono/mono/tests'
make[4]: *** [testjit] Error 2
make[4]: Leaving directory `/home/pi/mono/mono/tests'
make[3]: *** [check-am] Error 2
make[3]: Leaving directory `/home/pi/mono/mono/tests'
make[2]: *** [check-recursive] Error 1
make[2]: Leaving directory `/home/pi/mono/mono/tests'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/home/pi/mono/mono'
make: *** [check-recursive] Error 1
Any help trying to debug what's wrong is welcome, since i don't know where should i look.
I would add these questions to comment, but don't have enough reputation.
what is the output of ./autogen.sh at the end? Look at the libraries section. Do you have .NET 4.0 and .NET 4.5 'yes' in this section? If they are 'no', try run ./autogen.sh --with-profile4=yes --prefix=your_prefix
Libraries:
.NET 2.0/3.5: yes
.NET 4.0: yes
.NET 4.5: yes
why do you choose to install in /usr/local, when your system mono is located in /usr? You'll have two mono installation in different directories. This is useful, when you what to use parallel mono environments, but as far as I understand, you just want update mono to the latest version. I use --prefix=/usr in this case, to avoid issues of finding libraries in PATH.
these failed tests mean that some of mono functionality (related to PInvoke) won't work correctly on your platform but in general mono will work as expected (because all other tests were passed)
When I deploy a cloud service to Windows Azure it causes a number of VSPerf.exe instances to start - anything from 1 to 5.
Between them they consume all the CPU and none of the processes ever terminate themselves.
If I remotely connect to the instance and terminate the processes manually they restart on the next request. If the process is terminated during the request then the request succeeds and the page displays and functions as expected.
The only difference between this is a previous deployment is I have since upgraded to .NET 4.5 and therefore upgraded the cloud service to server 2012.
What could be causing this?
Update
For every failed start up 2 events are logged:
VsPerf Tool Error: Error starting data collection with a dedicated process D:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\VSPerf.
.NET Runtime version 4.0.30319.18010 - Loading profiler failed during CoCreateInstance. Profiler CLSID: '{44a86cad-f7ee-429c-83eb-f3cde3b87b70}'. HRESULT: 0x80040111. Process ID (decimal): 1444. Message ID: [0x2504].
Update 2
The VSPerf issue does not occur after a new instance is created or the machines are reimaged (at least thats a fix (an annoying and time consuming fix) for now).
Check the Azure publish settings in Visual Studio, I'd bet you have enabled profiling on the Advanced tab.
Same issue, 2 processes of VSPerf.exe burning 100% of CPU on 2nd role instance. IIS becomes unresponsive on that instance. We had the exact same issue 4 months back, disappeared "somehow" when profiling was enabled just when we were debugging this issue with MSFT support (someone inside MSFT knows this issue). But without being able to repro the issue (we only had screenshots) it was dropped.
Since I see it again, 5 minutes back and since Azure SDK 2.0 makes it easy to grab diagnostic logs (unlike the configuration ritual from SDK 1.8), here is something useful for the next folks to make sense off
The core error is Application VsPerf Tool Error: Error starting data collection with a dedicated process D:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\VSPerf. with the detailed logs (4 entries) below. Interestingly I had 2 processes of VSPerf.exe burning 100% of CPU and also had 2 log entries ....
{555908d1-a6d7-4695-8e1e-26931d2012f4} Service Control Manager 7011 System A timeout (30000 milliseconds) was reached while waiting for a transaction response from the iphlpsvc service. <Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'><System><Provider Name='Service Control Manager' Guid='{555908d1-a6d7-4695-8e1e-26931d2012f4}' EventSourceName='Service Control Manager'/><EventID Qualifiers='49152'>7011</EventID><Version>0</Version><Level>2</Level><Task>0</Task><Opcode>0</Opcode><Keywords>0x8080000000000000</Keywords><TimeCreated SystemTime='2013-06-23T17:37:25.557218700Z'/><EventRecordID>1269</EventRecordID><Correlation/><Execution ProcessID='520' ThreadID='1104'/><Channel>System</Channel><Computer>RD00155DA909B8</Computer><Security/></System><EventData><Data Name='param1'>30000</Data><Data Name='param2'>iphlpsvc</Data></EventData></Event> WebApp_IN_1 6/23/2013 5:37 PM 2 520 1104
{555908d1-a6d7-4695-8e1e-26931d2012f4} Service Control Manager 7011 System A timeout (30000 milliseconds) was reached while waiting for a transaction response from the Schedule service. <Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'><System><Provider Name='Service Control Manager' Guid='{555908d1-a6d7-4695-8e1e-26931d2012f4}' EventSourceName='Service Control Manager'/><EventID Qualifiers='49152'>7011</EventID><Version>0</Version><Level>2</Level><Task>0</Task><Opcode>0</Opcode><Keywords>0x8080000000000000</Keywords><TimeCreated SystemTime='2013-06-23T17:37:56.259560100Z'/><EventRecordID>1270</EventRecordID><Correlation/><Execution ProcessID='520' ThreadID='1104'/><Channel>System</Channel><Computer>RD00155DA909B8</Computer><Security/></System><EventData><Data Name='param1'>30000</Data><Data Name='param2'>Schedule</Data></EventData></Event> WebApp_IN_1 6/23/2013 5:37 PM 2 520 1104
00000000-0000-0000-0000-000000000000 VSPERF 4100 Application VsPerf Tool Error: Error starting data collection with a dedicated process D:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\VSPerf. <Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'><System><Provider Name='VSPERF'/><EventID Qualifiers='57635'>4100</EventID><Level>2</Level><Task>0</Task><Keywords>0x80000000000000</Keywords><TimeCreated SystemTime='2013-06-23T17:40:37.000000000Z'/><EventRecordID>266</EventRecordID><Channel>Application</Channel><Computer>RD00xxxxxxxxx</Computer><Security/></System><EventData><Data>Error starting data collection with a dedicated process D:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\VSPerf.</Data></EventData></Event> WebApp_IN_1 6/23/2013 5:40 PM 2 0 0
00000000-0000-0000-0000-000000000000 VSPERF 4100 Application VsPerf Tool Error: Error starting data collection with a dedicated process D:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\VSPerf. <Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'><System><Provider Name='VSPERF'/><EventID Qualifiers='57635'>4100</EventID><Level>2</Level><Task>0</Task><Keywords>0x80000000000000</Keywords><TimeCreated SystemTime='2013-06-23T17:40:41.000000000Z'/><EventRecordID>267</EventRecordID><Channel>Application</Channel><Computer>RD00xxxxxxxxx</Computer><Security/></System><EventData><Data>Error starting data collection with a dedicated process D:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\VSPerf.</Data></EventData></Event> WebApp_IN_1 6/23/2013 5:40 PM 2 0 0
The closest I've found to a workaround is to create a startup task
<Task commandLine="VSPerf.cmd" executionContext="elevated" taskType="background" />
where VSPerf.cmd is a simple launcher
PowerShell -ExecutionPolicy Unrestricted .\VSPerf.ps1
exit /B 0
for a PowerShell script which attempts to kill over-active VSPerf instances:
function Restart-VSPerf {
$procs = (
gwmi -Query "SELECT IDProcess,PercentProcessorTime FROM Win32_PerfFormattedData_PerfProc_Process WHERE Name='vsperf' AND PercentProcessorTime > 25" |
Foreach-Object { $_pid = $_.IDProcess ; gwmi -Query "SELECT Handle,CommandLine FROM win32_process WHERE Name='vsperf.exe' AND Handle=$_pid" | Select-Object Handle, CommandLine }
)
if ($procs) {
# Get VSPerf path.
# NB The regex uses conditional matching with an expression, as described in https://msdn.microsoft.com/en-us/library/36xybswe.aspx
# to ensure that a single capturing group gets the contents of quoted arguments and unquoted arguments.
$regex = [regex] '^(("?)((?(?<=")[^"]*|[^"\s]*))\2(\s+|$))+$'
$vsperf = $regex.Match($procs[0].CommandLine).Groups[3].Captures[0].Value
& $vsperf /detach
# Kill
$procs | Foreach-Object { Stop-Process -Force -Id $_.Handle }
# Restart
Start-Sleep -s 1
$procs | Foreach-Object {
$_args = ($regex.Match($_.CommandLine).Groups[3].Captures[1..99] | Select-Object -ExpandProperty Value)
Start-Process $vsperf -ArgumentList "$_args"
}
}
}
while (1) {
Start-Sleep -s 180
Restart-VSPerf
}
It works sometimes but not always. Suggestions for reliability improvements welcome.
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.