Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Bognar posted:

Adding to this, a simple but awesome feature that I find myself missing without R# is Move Type to File. Often when prototyping things I'll jam a bunch of classes together in a file, then come back afterwards and refactor into their own files - this is pretty painful with having to create each file manually then copying the code in and trying to get the using statements right.

One of my favourite ReSharper features that I think really needs to be in the base Visual Studio is the 'go to implementation'. When using DI it's basically a necessity, and I'm struggling without it.

Adbot
ADBOT LOVES YOU

mortarr
Apr 28, 2005

frozen meat at high speed

Bognar posted:

Adding to this, a simple but awesome feature that I find myself missing without R# is Move Type to File. Often when prototyping things I'll jam a bunch of classes together in a file, then come back afterwards and refactor into their own files - this is pretty painful with having to create each file manually then copying the code in and trying to get the using statements right.

How did I never know about this!

Mr Shiny Pants
Nov 12, 2012

The Wizard of Poz posted:

One of my favourite ReSharper features that I think really needs to be in the base Visual Studio is the 'go to implementation'. When using DI it's basically a necessity, and I'm struggling without it.

For this I usually use "go to definition (F12)." I don't think it is as powerful as R#'s " go to implementation" though.

Kekekela
Oct 28, 2004
Watching this discussion is illustrating my biggest problem with telling people what I like about Resharper, I can never remember which features are VS and which are R# :haw:

Sab669
Sep 24, 2009

The Wizard of Poz posted:

One of my favourite ReSharper features that I think really needs to be in the base Visual Studio is the 'go to implementation'. When using DI it's basically a necessity, and I'm struggling without it.

This alone is worth paying for, IMO.

Wish I ever worked anywhere that used it :(

RICHUNCLEPENNYBAGS
Dec 21, 2010

The Wizard of Poz posted:

One of my favourite ReSharper features that I think really needs to be in the base Visual Studio is the 'go to implementation'. When using DI it's basically a necessity, and I'm struggling without it.

On much the same note I love the shortcut that lets you add a private field to a constructor.

Mr Shiny Pants
Nov 12, 2012
Anyone know why a SSL HttpWebRequest fails on an IP Address connection?

I get a:
code:
 $exception	{"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."}	System.Exception {System.Net.WebException}
If I use the DNS name of the machine it works fine.

The weird part is that the certificate has Subject Alternative Names for the IP Address.

SANs on the cert:
code:
DNS Name=aziraphale
IP Address=169.254.80.80
IP Address=192.168.2.14

I don't know why this should fail, Chrome connects fine.

Edit: I seem to have fixed it.

This blog gave me an idea: http://www.michaelm.info/blog/?p=1281

It seems that the IP Address identifier is not parsed correctly in IE and Chrome ( does now though ). Thinking that IE probably uses the same Certificate code as .Net HttpWebRequest I modified my certificate generation code to generate the following:

code:
DNS Name=aziraphale
IP Address=169.254.80.80
DNS Name=169.254.80.80
IP Address=192.168.2.14
DNS Name=192.168.2.14

Lo and behold, it works.

I should probably drop the apipa Ip addresses :)

Mr Shiny Pants fucked around with this message at 17:27 on Jul 17, 2015

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Mr Shiny Pants posted:

For this I usually use "go to definition (F12)." I don't think it is as powerful as R#'s " go to implementation" though.

When you use the vanilla F12, it takes you to the definition that the context you're working in sees. So if you use a lot of DI and code against interfaces most of the time, F12 is going to take you to the method declaration in the interface, which is probably not what you want.

Mr Shiny Pants
Nov 12, 2012

Che Delilas posted:

When you use the vanilla F12, it takes you to the definition that the context you're working in sees. So if you use a lot of DI and code against interfaces most of the time, F12 is going to take you to the method declaration in the interface, which is probably not what you want.

Ah, that's why it was wonky sometimes :)

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Does anyone run into this developing universal apps, specifically on the RT/desktop side of things? I'm running VS2013 Ult.



The only somewhat fix I've found is deleting the bin/obj folders in the project and restarting VS, and even that rarely works. I've disabled and uninstalled all of my non-essential addons/extensions, so that's not it. What does always work is recloning from source control, so it's something to do with the autogenned code that VS does I think. I was hoping VS2015 would fix this, but I haven't resolved all the Win10 library issues yet to see.

It's frustrating not having intellisense pretty much ever for the XAML side of things.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

Knyteguy posted:

Does anyone run into this developing universal apps, specifically on the RT/desktop side of things? I'm running VS2013 Ult.



The only fix I've found is deleting the bin/obj folders in the project and restarting VS, and even that rarely works. I've disabled and uninstalled all of my addons/extensions, so that's not it. It's frustrating not having intellisense pretty much ever for the XAML side of things of creating these apps. The only thing that always works is recloning from source control, so it's something to do with the autogenned code that VS does I think. I was hoping VS2015 would fix this, but I haven't resolved all the Win10 library issues yet to see.

Are you talking UWP or "Universal" WinRT 8.1? You can't make UWP apps on VS2013, you need 2015. Also I'm 99% sure there is intellisense support for WinRT/UWP apps (at the very least there is with ReSharper). Also for UWP you need to be on 2015 RC. RTM won't work yet until they update the tools.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

Drastic Actions posted:

Are you talking UWP or "Universal" WinRT 8.1? You can't make UWP apps on VS2013, you need 2015. Also I'm 99% sure there is intellisense support for WinRT/UWP apps (at the very least there is with ReSharper). Also for UWP you need to be on 2015 RC. RTM won't work yet until they update the tools.

"Universal" WinRT 8.1. Yes normally Intellisense should work, but it thinks every element in XAML is invalid (very bottom gray box in the picture above). Basically the only way Intellisense works in XAML with this solution is if I reclone the entire solution to another folder and start new. It will then work until I close VS and re-open the project, at which point it will start to error out again. Sometimes deleting the obj/bin folders in the project folder, and the reopening the project will work.

e: a complete picture in case I'm doing something wrong here or something, as I'm relatively new to MVVM and wpf-like projects.


So it won't even recognize basic elements such as Page and Grid. Intellisense will work with the xml namespaces however (x:Name will show up, for example). :iiam:

e2: so I updated the SQLite runtime for both Windows 8.1 and Win 8.1 phone... and the problem may have gone away. I just did all the flag notification updates up top.

Knyteguy fucked around with this message at 19:40 on Jul 17, 2015

LiterallyAnything
Jul 11, 2008

by vyelkin
Hi all. Preface- I'm know a tiny bit of C# and VB.Net but one thing I never wrapped my head around before switching my 4-year to project management and system administration from programming is asynchronous threads.

I have the following code-

code:
private async Task SendMessage()
{
	if (!_connected) return;
	if (string.IsNullOrEmpty(messageTextBox.Text)) return;

	switch (messageTextBox.Text)
	{
		case "Start":
			messageTextBox.Text = "BS~SESSION~START~RESERVE~3~25";
			break;
		case "Brady":
			outputTextBox.AppendText("Enter your super-secret passcode:" + Environment.NewLine);
			
			//await _client.SendMessage(messageTextBox.Text);
			//await SendMessage(); Infinite loop.
			//var someTask = Task<string>.Factory.StartNew(() => sendButton_Click());
			//await sendButton_Click;

			if (messageTextBox.Text == secretPass)
			{
				outputTextBox.AppendText("Password accepted. Welcome." + Environment.NewLine);
			}
			else
			{
				outputTextBox.AppendText("Nope!" + Environment.NewLine);
			}
			messageTextBox.Text = "";
			return;
		case "Quit":
			Application.Exit();
			break;
		default:
			break;
	}

	RichTextBoxExtensions.AppendRichText(outputTextBox, "You:" + Environment.NewLine, Color.Blue);
	outputTextBox.AppendText(messageTextBox.Text + Environment.NewLine);

	await _client.SendMessage(messageTextBox.Text);
	messageTextBox.Text = "";
	messageTextBox.Focus();
}
My problem is, as you can see by the commented out lines there, I have no idea how to get it to wait for the user to enter a string and press the send button. Can anyone help?

LiterallyAnything fucked around with this message at 20:00 on Jul 17, 2015

Mr Shiny Pants
Nov 12, 2012

Brady posted:

Hi all. Preface- I'm know a tiny bit of C# and VB.Net but one thing I never wrapped my head around before switching my 4-year to project management and system administration from programming is asynchronous threads.

Snip

My problem is, as you can see by the commented out lines there, I have no idea how to get it to wait for the user to enter a string and press the send button. Can anyone help?

Why do you want it Async? Waiting for user input is inherently synchronous right? Execution should stop because you need something from the user.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
That wouldn't be threaded code anyway. When you use async/await in a GUI application, the default behavior is to capture the current synchronization context (the UI thread) and execute everything on there.

Mellow_
Sep 13, 2010

:frog:

Che Delilas posted:

When you use the vanilla F12, it takes you to the definition that the context you're working in sees. So if you use a lot of DI and code against interfaces most of the time, F12 is going to take you to the method declaration in the interface, which is probably not what you want.

I never used to mind this when I was using Ultimate, as visual studio would have a nice down arrow beside the declaration in the interface and clicking it would bring up a list of all implementations.

In anything below Ultimate you get the up arrow beside the implementation to take you back to the declaration, but not the other way around.

LiterallyAnything
Jul 11, 2008

by vyelkin

Mr Shiny Pants posted:

Why do you want it Async? Waiting for user input is inherently synchronous right? Execution should stop because you need something from the user.

Honest answer- I have no idea. I don't know crap about how to use Async so if anyone has any recommendations for materials specifically geared towards that subject I'd love to educate myself. Right now I'm trying to wrap my head around the MSDN materials but I feel like I need a primer.

But anyway no, the application just keeps going. I'm guessing if I made a pop-up prompt for the password the execution would stop but I didn't want to go that route.

Ithaqua posted:

That wouldn't be threaded code anyway. When you use async/await in a GUI application, the default behavior is to capture the current synchronization context (the UI thread) and execute everything on there.

This is good to know. So if I shouldn't be using await, what should I be using? Is this even possible given the way my current code is written or do I have to change that function and break it up?

Edit- Wait... is it really THIS simple?

var name = Console.ReadLine();

...although in my code since it's not the console and it's an input box in the GUI named "messageTextBox" I changed that line to "var name = messageTextBox.ReadLine();", but ReadLine is not part of TextBox.

LiterallyAnything fucked around with this message at 20:46 on Jul 17, 2015

Mellow_
Sep 13, 2010

:frog:

Brady posted:

Honest answer- I have no idea. I don't know crap about how to use Async so if anyone has any recommendations for materials specifically geared towards that subject I'd love to educate myself. Right now I'm trying to wrap my head around the MSDN materials but I feel like I need a primer.

But anyway no, the application just keeps going. I'm guessing if I made a pop-up prompt for the password the execution would stop but I didn't want to go that route.


This is good to know. So if I shouldn't be using await, what should I be using? Is this even possible given the way my current code is written or do I have to change that function and break it up?

Edit- Wait... is it really THIS simple?

var name = Console.ReadLine();

...although in my code since it's not the console and it's an input box in the GUI named "messageTextBox" I changed that line to "var name = messageTextBox.ReadLine();", but ReadLine is not part of TextBox.

Yep, it is that easy. I can't imagine why you would want an async input, as one would hope the rest of the process would be blocked until it obtained the input data it needs to continue from the user.

LiterallyAnything
Jul 11, 2008

by vyelkin

AuxPriest posted:

Yep, it is that easy. I can't imagine why you would want an async input, as one would hope the rest of the process would be blocked until it obtained the input data it needs to continue from the user.

Hmm, the thread still continues even after adding that though. I'm guessing it's because I'm not trying to read the text from a console window, but instead I'm wanting to wait until the user clicks "send" after entering a string in the messageTextBox. Does the fact that the entire function is async have anything to do with it?

Edit- I guess I could add a while statement in there that loops until the send button is clicked...

LiterallyAnything fucked around with this message at 21:01 on Jul 17, 2015

SirViver
Oct 22, 2008
I'm greatly confused by your code. What is your application supposed to do / what does it look like? The only thing I can think of it that it has a console/chat-like window (the RichTextBox) and a separate textbox messageTextBox which calls SendMessage() once you press enter or hit a send button?

Then on one special input "Brady" you want it to query for a password? If that is the case, I see two ways of doing that:
  1. Have a variable in your form class like bool waitingForPasswordInput = false;, which you set to true in the "Brady" input case and on the next SendMessage() call check if the input was the correct password, reset the variable and do whatever special logic you want to execute.

  2. Create a separate form with just a textbox for the password input and show that via ShowDialog(), which will block at this point. Once the dialog box is closed you can read what was in its password textbox and continue from there.

LiterallyAnything
Jul 11, 2008

by vyelkin

SirViver posted:

I'm greatly confused by your code. What is your application supposed to do / what does it look like? The only thing I can think of it that it has a console/chat-like window (the RichTextBox) and a separate textbox messageTextBox which calls SendMessage() once you press enter or hit a send button?

Then on one special input "Brady" you want it to query for a password?

Correct. The app is essentially a client to server communicator. Another goon is creating all the key parts of the application and I'm messing around with certain functionality that I need added (while hopefully not screwing up anything that he's doing along the way).

SirViver posted:

If that is the case, I see two ways of doing that:
  1. Have a variable in your form class like bool waitingForPasswordInput = false;, which you set to true in the "Brady" input case and on the next SendMessage() call check if the input was the correct password, reset the variable and do whatever special logic you want to execute.

  2. Create a separate form with just a textbox for the password input and show that via ShowDialog(), which will block at this point. Once the dialog box is closed you can read what was in its password textbox and continue from there.

I like the first option best. I know I can call a message box which will pause the thread and have the user enter it that way, but I'm wanting them to enter it in the same input box as everything else.

In order to implement what you said, how would I code it to wait for the next "sendMessage()" event? Or, do I return from that function and then... you know what, I think I got it.


Thank you all for all your help!

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

Brady posted:

Correct. The app is essentially a client to server communicator. Another goon is creating all the key parts of the application and I'm messing around with certain functionality that I need added (while hopefully not screwing up anything that he's doing along the way).

Okay, why does this need a GUI? Why can't this just be a console app?

LiterallyAnything
Jul 11, 2008

by vyelkin

Drastic Actions posted:

Okay, why does this need a GUI? Why can't this just be a console app?

It's going to be used by all sorts of users in the end and there's a lot more parts to it than I mentioned. I was just giving information that was relevant to my question.

Edit- Thanks again everyone. Got it working the way I wanted.

Here's the solution. I thought there would be something more elegant (such as the Console.ReadLine method), but this is just fine-

code:
private async Task SendMessage()
{
	if (!_connected) return;
	if (string.IsNullOrEmpty(messageTextBox.Text)) return;

	if (waitingForPasswordInput == true)
	{
		if (messageTextBox.Text == secretPass)
		{
			outputTextBox.AppendText("Password accepted. Welcome." + Environment.NewLine);
			//Add something here
		}
		else
		{
			outputTextBox.AppendText("Nope!" + Environment.NewLine);
		}
		waitingForPasswordInput = false;
		messageTextBox.Text = "";
		messageTextBox.Focus();
		return;
	}

	switch (messageTextBox.Text)
	{
		case "Start":
			messageTextBox.Text = "BS~SESSION~START~RESERVE~3~25";
			break;
		case "Brady":
			outputTextBox.AppendText("Enter your super-secret passcode:" + Environment.NewLine);
			waitingForPasswordInput = true;
			messageTextBox.Text = "";
			messageTextBox.Focus();
			return;
		case "Quit":
			Application.Exit();
			break;
		default:
			break;
	}

	RichTextBoxExtensions.AppendRichText(outputTextBox, "You:" + Environment.NewLine, Color.Blue);
	outputTextBox.AppendText(messageTextBox.Text + Environment.NewLine);

	await _client.SendMessage(messageTextBox.Text);
	messageTextBox.Text = "";
	messageTextBox.Focus();
}

LiterallyAnything fucked around with this message at 21:50 on Jul 17, 2015

Small White Dragon
Nov 23, 2007

No relation.
Hi all! I'm in the midst of porting/integrating old code with C#. While I've used C# before, this is my first time I've done low-level integration with C#, although I've done it in Objective C and Java via JNI. I went back to some of the documentation I read, but it's unclear on some things.

0) fixed() is pretty snazzy for a single call to old code, but is there a way to create a memory block that is essentially fixed for life?

1) Are structs in C# laid out the same way they are in C?

2) BitConverter uses the endianness of the machine it's on. Is there a way to use network byte order?

3) Is there any way to do conditional thread locks, similar to NSConditionLock in Objective C?

raminasi
Jan 25, 2005

a last drink with no ice

Small White Dragon posted:

1) Are structs in C# laid out the same way they are in C?

I don't know the answers to your other questions, but the answer to this one is "no".

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Small White Dragon posted:

2) BitConverter uses the endianness of the machine it's on. Is there a way to use network byte order?

You can use the static helper method IPAddress.HostToNetworkOrder:

https://msdn.microsoft.com/en-us/library/653kcke1.aspx

Or you can manually check BitConverter.IsLittleEndian.

Potassium Problems
Sep 28, 2001

Small White Dragon posted:

2) BitConverter uses the endianness of the machine it's on. Is there a way to use network byte order?

I've always used something like this:

code:
if(BitConverter.IsLittleEndian)
{
  Array.Reverse(bytes)
}

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Ugh, this isn't .net specific (I don't think), but when I connect to a url via a web client, it returns a 500 internal server error. I can visit that URL in my browser just fine. This was working for months and the problem started yesterday.

Example url: http://www.myfitnesspal.com/reports/printable_diary/chuckgross?from=2015-07-17&to=2015-07-17

The code:
code:
string results;

using (var client = new WebClient())
 {
     results = client.DownloadString(url);
}
This gives the exception: The remote server returned an error: 500.

Using Fiddler, I'm seeing a page returned that is their "Site Down" page with the message: "Sorry, but a server error occurred processing your request. Our team has been notified of the issue".

Is there anything that I can do given that the URL itself works fine in a browser? Any alternative ways to try to troubleshoot?

Edit: This fixed it: client.Headers["User-Agent"] = "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)";

Uziel fucked around with this message at 15:18 on Jul 18, 2015

Mr Shiny Pants
Nov 12, 2012

Uziel posted:

Ugh, this isn't .net specific (I don't think), but when I connect to a url via a web client, it returns a 500 internal server error. I can visit that URL in my browser just fine. This was working for months and the problem started yesterday.

Example url: http://www.myfitnesspal.com/reports/printable_diary/chuckgross?from=2015-07-17&to=2015-07-17

The code:
code:
string results;

using (var client = new WebClient())
 {
     results = client.DownloadString(url);
}
This gives the exception: The remote server returned an error: 500.

Using Fiddler, I'm seeing a page returned that is their "Site Down" page with the message: "Sorry, but a server error occurred processing your request. Our team has been notified of the issue".

Is there anything that I can do given that the URL itself works fine in a browser? Any alternative ways to try to troubleshoot?

You could try setting your webclient useragent with one from a browser and see if that works. Could be that they filter on useragent string.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Mr Shiny Pants posted:

You could try setting your webclient useragent with one from a browser and see if that works. Could be that they filter on useragent string.
Yep, that was definitely it. Thanks! They must have just added that.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

Small White Dragon posted:

0) fixed() is pretty snazzy for a single call to old code, but is there a way to create a memory block that is essentially fixed for life?
Unless you mean some sort of operating system construct like shared memory, no. The GC needs to be able to move stuff around in memory.

quote:

1) Are structs in C# laid out the same way they are in C?
No, unless you have an explicit layout for interop purposes, the runtime reserves the right to reorder the fields as it pleases.

Mr Shiny Pants
Nov 12, 2012
I am writing a F# program and need a timer. What is a good timer for F#?

In C# I have used the RX observable.FromTimespan with good results, but RX is pretty ugly to use in F# because of the overloaded nature of most methods.

Is System.Timer the best?

I saw one using a MailboxProcessor with do! async sleep in it which I thought was pretty funky.

raminasi
Jan 25, 2005

a last drink with no ice

Mr Shiny Pants posted:

I am writing a F# program and need a timer. What is a good timer for F#?

In C# I have used the RX observable.FromTimespan with good results, but RX is pretty ugly to use in F# because of the overloaded nature of most methods.

Is System.Timer the best?

I saw one using a MailboxProcessor with do! async sleep in it which I thought was pretty funky.

How do overloaded methods make it ugly to use?

Mr Shiny Pants
Nov 12, 2012

GrumpyDoctor posted:

How do overloaded methods make it ugly to use?

I've tried to use it in a simple way as I did from C# and the compiler would usually go: Error 1 Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.

So you have explicitly tell it which version of the method you want to use and nudge the compiler in the right direction. After first figuring out what the explicit types are.

Maybe I should take another look.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Mr Shiny Pants posted:

I am writing a F# program and need a timer. What is a good timer for F#?

In C# I have used the RX observable.FromTimespan with good results, but RX is pretty ugly to use in F# because of the overloaded nature of most methods.

Is System.Timer the best?

I saw one using a MailboxProcessor with do! async sleep in it which I thought was pretty funky.

Have you read this implementation with Timer and (F#) Observable? It doesn't look particularly ugly to me.

raminasi
Jan 25, 2005

a last drink with no ice

Mr Shiny Pants posted:

I've tried to use it in a simple way as I did from C# and the compiler would usually go: Error 1 Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.

So you have explicitly tell it which version of the method you want to use and nudge the compiler in the right direction. After first figuring out what the explicit types are.

Maybe I should take another look.

I'm curious to see some example code, because I've never encountered a situation in F# where I needed more type annotations than corresponding C# code.

Mr Shiny Pants
Nov 12, 2012
I don't have examples ready, but I tried converting my C# ToObservable code and it was really awkward.

Any operation that takes a func might be a good example.

I found this on stackoverflow: http://stackoverflow.com/questions/8777975/f-rx-converting-async-patterns-to-observable-sequences

The problem is really that I've used Rx for more than just a timer in my C# code, but to just take on the dependency for a timer is maybe a bit much.

I might just try it again, sometimes leaving something for awhile and returning to it after a time works best.



I might try this, thanks.

Edit: Another question: How can you download multiple files from a webserver in one request? Is there something like multipart/formdata for downloading? Or would zipping the files be a better option so you get one file?

Mr Shiny Pants fucked around with this message at 12:25 on Jul 19, 2015

raminasi
Jan 25, 2005

a last drink with no ice

Mr Shiny Pants posted:

The problem is really that I've used Rx for more than just a timer in my C# code, but to just take on the dependency for a timer is maybe a bit much.

This was the other thing I was thinking.

Adhemar
Jan 21, 2004

Kellner, da ist ein scheussliches Biest in meiner Suppe.

Inverness posted:

Unless you mean some sort of operating system construct like shared memory, no. The GC needs to be able to move stuff around in memory.

It doesn't have to be shared memory. You could allocate unmanaged memory and the GC won't touch it.

Small White Dragon posted:

0) fixed() is pretty snazzy for a single call to old code, but is there a way to create a memory block that is essentially fixed for life?

Take a look at Marshal.AllocHGlobal(): https://msdn.microsoft.com/en-us/library/s69bkh17.aspx

Only do this if you have no other choice though.

Adbot
ADBOT LOVES YOU

EssOEss
Oct 23, 2006
128-bit approved

epalm posted:

code:
EntityCommandExecutionException: An error occurred while executing the command definition.
    See the inner exception for details.
SqlException: A transport-level error has occurred when receiving results from the server.
    (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
Win32Exception: The semaphore timeout period has expired
...
at System.Data.Entity.DbSet`1.Find(Object[] keyValues)
I'm getting these exceptions randomly. I cannot reproduce them. They seem to occur when I'm doing a simple Find() query. So far it's happened 6 times this morning, so it's more than "once in a while". Apparently they're happening because SQL Server is being moved around their datacenter. Various SO posts tell me I need to use the System.Data.Entity.SqlServer.SqlAzureExecutionStrategy instead of System.Data.Entity.Infrastructure.DefaultExecutionStrategy, to deal with that. But now transactions are broken, because they aren't supported by SqlAzureExecutionStrategy.

I can confirm that I experience the same type of random interruptions multiple times a day. 10 GB database, quite low load (average 1 request per second). Funny thing is that SqlAzureExecutionStrategy does not catch all of the random errors! We had to add some custom retry logic on top for whatever reason, to really make it retry on all the retry-worthy cases.

Overall, though, going the retry logic route has worked fine for us. It is a bit disconcerting coming from an oldschool "What do you mean it goes down arbitrarily?!" perspective but I suppose it's a good way to ensure the app is fault tolerant :)

The limit on manual transactions has not proven to be an issue so far, since I have taken care not to introduce any to the application. Perhaps you can re-engineer your app not to require them?

EssOEss fucked around with this message at 11:43 on Jul 20, 2015

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply