Import-Module will not work when launched from .net

I'm trying to run a powershell script within my C# web application. When i run the following in powershell, it works fine. Import-Module 'C:\\Program Files\\Microsoft Dynamics NAV\\80\\Service\\NavAdminTool.ps1' Get-NAVTenant -ServerInstance Dynamics

How to develop environment variables with substitutions?

Goal We are using environment variables like %logonserver% and %userdomain% in our .NET application's configuration files, to support configuration freedom to application managers. When parsing the configuration file a call to Environment.ExpandEnvir

When is an HTTP response complete?

I am writing a simple HTTP client in .NET for learning purposes. I am using the .NET Socket class, which ultimately uses Winsock. I do not want to use the WebRequest, HttpWebRequest, or HttpClient classes, as they use WinINet, which I do not want to

Iterative process to return the second lowest value

I am fairly new to and cannot find any specific help after several hours of searching. I have a table of data points with three columns, column 1 is the "point id", column 2 is the "x co-ordinate" and column 3 is the "y co-

Linq's first method giving an error

In my webmethod of my WCF rest service i am trying to find record using Linq's First method like below [WebInvoke(UriTemplate = "UpdateProductObject", Method = "PUT")] public Result UpdateProductObject(ProductObjectToSave prodSave) { I

Regex is the table of contents schema

Considering NN = number/digit x = any single letter I want to match these patterns: 1. NN 2. NNx 3. NN.NN 4. NN.NNx 5. NN.NN.NN 6. NN.NN.NNx Example that needs to be match: 1. 20 2. 20a 3. 20.20 4. 20.20a 5. 20.20.20 6. 20.20.20a Right now I am tryin

System namespace in another DLL

Here's my problem: I am using a DLL library (not from the .NET framework) which contains a System namespace with the Tuple and Lazy classes. When I try to compile my project the compiler throws some errors stating that these classes exist in mscorlib

Entity Framework - Entities with Inherited Properties

I searched the threads on here and found multiple similar posts but no solutions Assume I have a User table in my db that I've mapped to a simple User entity public class User{ public int UserId {get;set;} public string Username {get;set;} } I want t

How to search all user accounts in a domain in .NET?

How do I search all the user accounts in a domain in .NET? Not the computer names in the domain, but the user accounts, that's what you are using to log on Windows.You can try the following. PrincipalContext ctx = new PrincipalContext(ContextType.Mac

Visual Studio installation project running very slowly

I have created a Visual Studio 2010 setup project, which contains two executable files and some additional xml files. The overall size is about 2mb and installing is just a simple copying to ProgramFiles with adding icons to desktop and start menu. B

Best approach to Triggering Event on the SQL database

Quite simply I have a SQL database with a .net front end and I need to set off event's when an specific time is reached . I call them alarms , so a user can set an alarm for say 12:30am on x day and when that time is reached on x day a popup would ap search and use a filter to limit the results

As usual I turn to the massive brain power that is the Stackoverflow user base to help solve a Lucene.NET problem I am battling with. First off, I am a complete noob when it comes to Lucene and Lucene.NET and by using the scattered tutorials and code

C # Dictionary.ContainsKey () always returns false

I have a Dictionary and every time I call the ContainsKey method it returns false. Take the following example Boolean found = dict.ContainsKey(new Group("group1", "test")); The found variable is false eventhough the visual studio debug

How to create an XpsDocument from a byte array?

I would like to create a new System.Windows.Xps.Packaging.XpsDocument object from byte array, as I will not want to store it immediately on a local machine. By using a temp file it works fine: public static XpsDocument OpenXpsDocument(string url) { W

.net: Version numbers for DLL vs EXE?

I have been recently versioning my product (exe) and increasing the build number each time in assemblyinfo.cs. Works great, my product is currently on version 1.5.x.x so in increase the 4 digit each time i have a succesful build. Now i have my DLLs w

The Moq check method fails even if the method will be called

I have some troubles using Moq. Following unit test throws an exception, even though the according method will be called. [TestMethod] public void CreateFinishTest() { // mock methods factoryMock.Setup(f => f.LoadPlan("TestPlanDoNotUse")).Ret

How to convert a hexadecimal string into a signed integer?

I'm getting a hex string that needs to be converted to a signed 8-bit integer. Currently I'm converting using Int16/Int32, which will obviously not give me a negative value for an 8-bit integer. If I get the value 255 in Hex, how do I convert that to

Can a VS project generate two runtime files?

I want to develop a application including two execute files(one as main entry,the other as upgrader). I'm wondering if the two execute files can be generated in a VS project ? if can't,are there better way to develop the two execute files? and how to

C # Class / Interface calling method (native code, cost)

Suppose we have some class A that implements some interface I I i = new A(); i.method(); // example 1 A a = (A)i; a.method() // example 2 The IL code generated for each call to "method()" is same, but which one of invocations to method "met

Binary File Analysis Libraries for .NET

Recently I had a task to make a binary files parser, however it was the first time of using C#/.NET for this kind of problems. It was really simple to parse and extract data from the required binary files because of their simple structure (though I h

Thread Safe Method

Sup Guys, I Have a Function on my frmMain Class wich will update my control to something else after an invoke. When i type "?Label1.Text" on the Immediate Window, the text property IS updated, but when i go check the Form, nothing happened. The