Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex Class - Assembly Reference Missing?

Tags:

c#

regex

.net-4.5

I'm defining a new class. Two issues:

Match m = Regex.Match(text, pattern, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1));

Gives this error: "No overload for method 'Match' takes 4 arguments". But the MSDN defines this with 4 args.

catch (RegexMatchTimeoutException)

Gives this error: "The type or namespace name 'RegexMatchTimeoutException' could not be found (are you missing a using directive or an assembly reference?)"

My using directives:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

I'm running VS2008Express with .NET4.5

like image 802
Tim Bostwick Avatar asked Sep 14 '26 18:09

Tim Bostwick


1 Answers

The overload of Match method which takes 4 arguments was only introduced in .NET 4.5. The problem is, you can not use Visual Studio 2008 to develop .NET 4 and later apps. See ScottGu's Blog:

There isn't any way to target .NET 4 from VS08 and use new features. Having said that, .NET4 is upwards comaptible with .NET 3.5 - so applications you build targeting .NET 3.5 with VS08 should work fine on top of .NET 4.

Also, check out this question.

like image 77
Dmitrii Erokhin Avatar answered Sep 17 '26 09:09

Dmitrii Erokhin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!