C # - Using the method from a Python file

I have two files, a regular python (.py) file and a visual studio C# file (.cs). I want to use a function in the python file which returns a string and use that string in the C# file. Basically: #This is the Python file! def pythonString(): return "S

Error when calling Task.Run to create an asynchronous process

I've been reviewing the code an app dev company has been doing for me in Xamarin. When I try to compile namespace AppName.Droid public class SplashActivity : AppCompatActivity { protected override void OnStart () { base.OnStart (); Task.Run (Login);

Generic method for multiple db tables

I have multiple tables with the same structure and want to write a generic function that return data from the correct table. Now: var a = context.TableA.Where(a => a.id == id).FirstOrDefault.Name; var b = context.TableB.Where(b => b.id == id).FirstO

Braintree Dropin UI, how to detect the type of card?

I am using Braintree Dropin UI, I need to find out the Card Type like AMEX, VISA, etc. I am using JS + .NET. This is my Payment request code: var request = new TransactionRequest { Amount = Math.Round(amount, 2), PaymentMethodNonce = nonce, MerchantA

Is there a way to synchronously use the MongoDB C # driver?

I have a 2 layered C# project. The 1st one is a data layer which connects to mongodb and sends collections to the web service layer. The problem is that I couldn't find in the new driver non-async methods (i.e. synchronous). Is there a way to use syn

Keep the last path selected using OpenFileDialog / C # / .Net

I want to keep the last path which is selected. This is the code: private void testFileButton_Click(object sender, EventArgs e) { fd = new OpenFileDialog(); fd.FileName = testParameters.testFileFile; fd.InitialDirectory = testParameters.testFileDir;

How to switch between TextBox and RichTextBox via templates

I want to write a TextBox control which is a RichTextBox when it is out of focus, and when it is focused it becomes a TextBox. I tried several methods, but none of them are working. The only solution that is almost working, looks like this: <RichText

Why is it important to have / close a WCF client proxy

I heard that it's essential to Dispose (or Close) a WCF client proxy even when you're not using sessions there are no unmanaged resources that need deterministic clean up (e.g. open sockets) For example, when using a BasicHttpBinding with the default

Each item in a collection in VB.Net

Nearly identical to How can I get every nth item from a List<T>? But I'm having trouble turning List<T> list = originalList.Where((t,i) => (i % 5) == 0).ToList(); Into VB.Net code.Literally, that would be: dim list as List(of T) = originalL

Reflection, Get the return value of a method

How can we exacute a method and get the return value from Reflection. Type serviceType = Type.GetType("class", true); var service = Activator.CreateInstance(serviceType); serviceType.InvokeMember("GetAll", BindingFlags.InvokeMethod, Ty

Reading the CSV file and storing the values ​​in a table

I am trying to read a *.csv-file. The *.csv-file consist of two columns separated by semicolon (";"). I am able to read the *.csv-file using StreamReader and able to separate each line by using the Split() function. I want to store each column i

What is MD5 doing with my password string?

I set my password "13579" and the authentication mode forms convert it to MD5 like "mEXg8klnq0TwPFvAqytULA==" but after couples of minutes I tried again and create another one by the same password "13579" but it converts to d

WCF downloads file control

I'm writing an application that controls the client downloads, I need know when a download is successful, but I need do it in the server side, but i don't find something like this. This is my Server code: public GetCoverResponse GetCover(GetCoverRequ

How to write the contents of a file to another file?

I need to write contents of a file to another file using File.OpenRead and File.OpenWrite methods. I am unable to figure out how to do it. How can i modify the following code to work for me. using (FileStream stream = File.OpenRead("C:\\file1.txt&quo

Storing configuration data in SQLite

I have a fairly complex winforms application and I m contemplating storing my config data in a sqllite db file rather than the ususal regular app.config/ xml files. The reasons being - Data in a db is more resilient to accidental changes by administr

Problem with MSHTML COM by clicking on the submit button

I'm having a problem screenscraping some data from this website using the MSHTML COM component. I have a WebBrowser control on my WPF form. The code where I retrieve the HMTL elements is in the WebBrowser LoadCompleted events. After I set the values

Will .NET be portable one day?

Not only Compact Framework. I know about Mono, but it will always be one step behind .NET.Not unless there are some serious industry shifts. Everything MS does is to keep you tied to their platform and their products. .Net keeps people on windows whi

C #: Create CPU usage at a custom percentage

I'm looking to test system responsiveness etc. on a few machines under certain CPU usage conditions. Unfortunately I can only create ~100% usage (infinite loop) or not enough CPU usage (I'm using C#). Is there any way, in rough approximation, as othe

Where are the .Net data types stored?

Where are the .Net data types stored?All core CTS types like Int16, Int32, Int64, String , Byte and etc. are defined in MSCorLib.dll. This file can be found in C:\Windows\Microsoft.NET\Framework\v2.0.50727 directory. All other special purpose types a

Synchronize content across multiple servers

We have a site which sits on two load balanced application servers (Win 2K3) which comprises a C#/ASP.NET app and a bunch of static content which changes on a daily basis. My question is, what's the best way to keep the static content in sync. In Win

Refactoring method that binds controls to LINQ

I have a function that binds LINQ results to the controls on my form. The below code works but I just can't get over the feeling I should be slapped for the copy/paste aspect. Can someone help me with what i need to do to deodorize this? Thank You! p

WCF, ASP.NET membership provider and authentication service

I have written a Silverlight 2 application communicating with a WCF service (BasicHttpBinding). The site hosting the Silverlight content is protected using a ASP.NET Membership Provider. I can access the current user using HttpContext.Current.User.Id