UserPrincipal.Current.EmailAddress not working when application is launched after install - c#

To make my console application launch after install I have added an installer class to my project.
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(this.Context.Parameters["AssemblyPath"]) + #"\MyAppName.exe");
}
I have added custom actions to my SetupProject (shortcut to Primary output MyApp.exe under Install and Commit) to execute launch after install and it does launch the app.
However when the app launches after install, and Main() runs UserPrincipal.Current.EmailAddress; I get this error:
Unable to cast object of type
'System.DirectoryServices.AccountManagement.GroupPrincipal'
to type 'System.DirectoryServices.AccountManagement.UserPrincipal'.
(This is on my workplace network by the way).
Now if I go to the application folder and run the .exe.... it works.
So my question is: what is it about the "run after install" method that's making this happen and how can I fix it?
I've tried almost every corner of the internet but cant get my head around this and many other solutions haven't worked.
I've tried solutions from this SO post with no luck.
I've tried getting the email address from outlook instead but I get a different error (which doesnt happen during debug or from clicking the .exe).

Related

CSC : error CS7028: Error signing output with public key from container 'Container' -- The file exists. [lgw0hqij.tmp_proj]

We had a Jenkins job running without issues for a couple of months now but recently it started failing.
It has this error when running form Jenkins:
CSC : error CS7028: Error signing output with public key from container 'Container_ID' -- The file exists. [lgw0hqij.tmp_proj]
It seems to rename the file every time.
I have logged into the host and executed as the user but it gives no error when running normally.
Once I run the user as an administrator, it starts giving the issue.
Running the application from Visual Studio does not give an issue at all!
I have tried running Jenkins as a LocalService as well as a lower privileged user, but same result.
I have also followed this, but doesn't seem to help.
I'm running out of ideas
EDIT
For anyone facing the same issue in the future. This error is linked to the user account temp folder
C:\Users\<username>\AppData\Local\Temp
Once you clear this folder, your msbuild should be working fine
For anyone facing the same issue in the future. This error is linked to the user account temp folder
C:\Users\<username>\AppData\Local\Temp
Once you clear this folder, your msbuild should be working fine

Failed to load native library grpc_csharp_ext.x86.dll while running Azure Function in Visual Studio

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

Username/Pass request during WinService installation

I have done a test Win service to make sure I have the Installer project (which is the part of that project and is set to InstallShield Limited by default) works fine.
I've searched for the correct manual and did the same as it was suggested:
Pls, see the WinService Installation class definition:
Then I tried both ways
1)
2)
Then I successfully build the Installation project and get the setup package..
As you can see everything is set to be installed under the Local user..
But each time I run the installation pask it asks for credentials..
My question is: how to avoid that dialog during installation?
Actually, I found the solution by myself.
The start point should be: To make yourself sure that the service is installable manually using InstallUtil.
In my case I mistakenly named ServiceName in AfterInstall event, when engaged Service Controller.. missed letter "1"
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
using (ServiceController sc = new ServiceController(serviceInstaller1.ServiceName))
{
sc.Start();
}
}
After that I changed the settings in InstallShield Project..
1) I dropped the added service at screen Way#1
2) Add InstallClass as it shown on Way#2
The request of the credential was because inside the service itself, I missed setting LocalSystem for Property Account of Service Process Installer in the Design Mode.
So, now it works..

Unable to run Console Application from Visual Studio: System.AccessViolationException

Description
When launching any Console Application, the code stops running immediately on an AccessViolationException (Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt). More info included in the next section.
Technical Symptoms
The Call Stack only contains external code:
Exception:Thrown: "The message filter indicated that the application is busy. >(Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))" (System.Runtime.InteropServices.COMException)
A System.Runtime.InteropServices.COMException was thrown: "The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))"
Time: 12/10/2015 10:59:55 AM
Thread:vshost.NotifyLoad[15344]
I created a new Console Application, containing only Console.WriteLine("Hello world!");
Running the new Hello world app results in the same exception and an identical
call stack.
Background
I suspect this has nothing to do with the issue, as I will explain, but I feel it is important to answer the obvious question, "what were you doing when the issue happend?" The last change I made was adding an extension to my Selenium Driver to hotkey logout from an application:
public static void logout(this IWebDriver Driver)
{
Driver.FindElement(By.TagName("body")).Click();
new Actions(Driver)
.SendKeys(Keys.Control + Keys.Shift + "x")
.Perform();
}
I also made a change in my App.Config file for one of my projects, but reverting this had no impact either.
Removing this code (the Driver extension and/or the App.Config change) does not resolve this issue. Retrieving a previous check-in does not resolve the issue. I am the only person currently working on this solution.
Discoveries
As mentioned, this is happening for an empty Console Application. Windows Form Applications launch fine. Unit Test Projects launch fine as well.
Research
I've spent hours looking into this. It seems like every similar issue I have looked into is pertinent to debugging only or a .NET version. For me, the issue occurs with a Release as well. Additionally, I have been using .NET 4.5 without any issues or changes on that front. I can't find any articles that seem worth posting, but I might be overlooking something.
Visual Studio Info
Microsoft Visual Studio Ultimate 2013
Version 12.0.30501.00 Update 2
.NET Version 4.6.00081 (just noticed it says 4.5 in my project properties, though)
Running as Administrator
Feedback
When Running from devenv.exe /SafeMode, Visual Studio loaded with:
An exception was encountered while constructing the content of this frame. This information is also logged in "C:\Users\UserName\AppData\Roaming\Microsoft\VisualStudio\12.0\ActivityLog.xml".
Exception details:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.VisualStudio.Shell.Interop.IVsShell5.LoadPackageWithContext(Guid& packageGuid, Int32 reason, Guid& context)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.GetPackage()
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()
Additionally, when trying to run, I get an error message of "Error while trying to run project: Invalid Pointer" (again, VS in devenv.exe /SafeMode - see how to run visual studio without plugin and all third party feature if unfamiliar)
Please let me know if I can provide any additional information.
It may be because when you name the project you can't put spaces, I put them and it gave me a AccessViolationException aswell, try using capitals to separate your words, but only use letters and no spaces to be sure.
I also faced this issue with Visual Studio 2010. More interestingly I had several projects in my solution (Console application, WPF application, Windows Forms application) but it was failing only when, I was setting the project which was of type "Console Application" as start up project. Following change finally helped me nail down the issue: Go to project properties of the console application project -> Go to "Debug" tab -> Go to "Enable Debuggers" section in right pane -> Check the "Enable unmanaged code debugging" check box as shown in the snapshot below. Root cause of why it happened is still not known to me. Only thing which I observed as fishy was that there were lot of windows updates which had got installed on my machine the previous night which mostly constituted of office updates and OS updates (More than a dozen KB articles).

Upgrading wp8 to wp8.1 silverlight, debugger cannot be launched

I have now had an error with VS2013 and WP8.1 silverlight for a couple of days.
I get a couple of different errors, ..Ensure unlocked screen.., AgHost.exe could not be launched, port is in use by another program and ensure the device is unlocked.
These errors came suddenly after I retarged the solution. I have no compiling errors.
Solution Attempts
Restart PC
Restart program
unregister and reregister the phone
reinstall Update 3
reinstall VS2013
Windows Phone 8 Application crash once its launched AgHost.exe' has exited with code -532265403
Install VS2015 with no luck.
reinstall VS2013 Update 4
Nothing worked. The error is also the same for emulator as well as different devices. I can however get the release mode installed. Break points can be used when using release mode, but I have to Clean, Rebuild and then deploy for every time I want to deploy the application. Further the deploy time has gone up exponentially. Before upgrading I used a maximum of 10 seconds. Now it is above a minute in wait time. :/
Anyone has a solution for this ?
Extra
If I run the solution before upgrade on device or Emulator It spins up with debugger. If then go to the updated WP81, I get a popup with info Something is taking longer then normal and then it crashes with ..Ensure unlocked screen.. :/
Could it be an issue with the differen SDKS?
During a repair of all the SDKs, I found an issue with the event log, which I cleared based on The Event Log File is full
Still no success.
Extra
I cannot spin up the emulator from VS2013, when using the WP8.1 solution, but the wp8.0 solution in the same VS works :S
I found an error in a log file, from:
The errors are:
[0F08:14A8][2015-07-23T09:11:44]: Applying execute package: silverlight5_DRT, action: Repair, path: C:\ProgramData\Package Cache\DEB5078B60B74431E2830831EB48DF129CB32932\packages\Silverlight\5.0_DRT\Silverlight_Developer.exe, arguments: '"C:\ProgramData\Package Cache\DEB5078B60B74431E2830831EB48DF129CB32932\packages\Silverlight\5.0_DRT\Silverlight_Developer.exe" /q /ignorewarnings'
[0F08:14A8][2015-07-23T09:11:45]: Error 0x800705de: Process returned error: 0x5de
[0F08:14A8][2015-07-23T09:11:45]: Error 0x800705de: Failed to execute EXE package.
[0550:0E74][2015-07-23T09:11:45]: Error 0x800705de: Failed to configure per-machine EXE package.
[0550:0E74][2015-07-23T09:11:45]: MUX: Installation size in bytes for package: silverlight5_DRT MaxAppDrive: 0 MaxSysDrive: 0 AppDrive: 0 SysDrive: 0
AND
[0F08:14A8][2015-07-23T09:16:16]: Applying execute package:
{312d9252-c71c-4c84-b171-f4ad46e22098}, action: Repair, path:
C:\ProgramData\Package
Cache{312d9252-c71c-4c84-b171-f4ad46e22098}\VS2012.4.exe, arguments:
'"C:\ProgramData\Package
Cache{312d9252-c71c-4c84-b171-f4ad46e22098}\VS2012.4.exe" -repair
-quiet -burn.related.patch' [0F08:14A8][2015-07-23T09:16:23]: Error 0x80048bc7: Process returned error: 0x80048bc7
[0F08:14A8][2015-07-23T09:16:23]: Error 0x80048bc7: Failed to execute
EXE package. [0550:0E74][2015-07-23T09:16:23]: Error 0x80048bc7:
Failed to configure per-machine EXE package.
Anybody knows what to do with this? The error is coming when I repair Windows Phone SDK 8.0
There was a post-VS2013 update for the Windows Phone 8.1 SDK, some odds that you don't have it installed since you did not need it before. The download location is here.
Getting error messages like "port is in use" when there's no obvious reason why it should be in use and seeing excessive download times is also a very strong selector for your installed anti-malware product getting in the way. No specific advice on how to configure it when we don't know what it might be. You definitely first want to try to temporarily disable it so you can identify it as the source of the problem.
I have no Idea of what is the issue, but creating a new solution and importing the existing projects into a new solution has solved all the issues regarding emulator and debugger an AgHost.
Seems like the upgrade function integrated in the solution did not work properly.

Categories