Here is my code. Everything works fine the first time I run it, i.e. HttpNotificationChannel.Find() returns null.
But the second time I run it, Find() returns the proper thing, however when I get to the Open() call, it throws an exception. Which is really odd, since Open() doesn't take any arguments.
What am I doing wrong?
public string ChannelName = "MyAppChannel";
...
NotificationChannel = HttpNotificationChannel.Find(ChannelName);
if (NotificationChannel == null)
{
NotificationChannel = new HttpNotificationChannel(ChannelName);
}
NotificationChannel.ChannelUriUpdated += new EventHandler(Channel_ChannelUriUpdated);
NotificationChannel.HttpNotificationReceived += new EventHandler(NotificationChannel_HttpNotificationReceived);
NotificationChannel.ErrorOccurred += new EventHandler(Channel_ErrorOccurred);
NotificationChannel.Open(); // <-- Kaboom here, the 2nd time
Here's the full text and stack:
System.ArgumentException: E_INVALIDARG
at Microsoft.Phone.Notification.SafeNativeMethods.ThrowExceptionFromHResult(Int32 hr, Exception defaultException, NotificationType type)
at Microsoft.Phone.Notification.HttpNotificationChannel.Open()
at LiveShare.NotificationManager.Initialize()
at LiveShare.App..ctor()
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at MS.Internal.TypeProxy.<>c__DisplayClass30.b__2a()
at MS.Internal.TypeProxy.CreateInstance(UInt32 customTypeId)
at MS.Internal.FrameworkCallbacks.CreateKnownObject(IntPtr nativeRootPeer, UInt32 customTypeId, String initializationString, IntPtr& nativePeer, UInt32 isCreatedByParser)
at MS.Internal.FrameworkCallbacks.CreateUnknownObject(String assemblyName, String typeName, IntPtr nativeRootPeer, String initializationString, UInt32& customTypeId, UInt32& coreTypeId, UInt32& typeFlags, IntPtr& nativePeer)
The correct solution is not to call Open() if Find() succeeds.
This looks very similar to a documented problem with the CTP as described by Nick Harris last April.
Solution: If you try to Open a channel almost immediately after you hit Debug when emulator fires up this issue will occur. The solution is simple – Give the emulator two minutes before making the call.
In case that's not it, there's a good article on Silverlight Show that covers push notifications in a WP7 stock quote app.
Related
When setting the Linker behaviour to "Link all" I get the following error at runtime:
Autofac.Core.DependencyResolutionException.
I've tried adding ignore assembly Autofac but without success.
Setting the Linker behavior to "Link Framework SDKs only" does work but I want to enable "Link All" if possible.
Thanks in advance.
Update :
ReflectionActivator.ActivateInstance (Autofac.IComponentContext context, System.Collections.Generic.IEnumerable`1[T] parameters)
Autofac.Core.DependencyResolutionException: No constructors on type 'Eela.Taxi.Service.RestService' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
No constructors on type 'Eela.Taxi.Service.RestService' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = RestService (ReflectionActivator), Services = [Eela.Model.Xamarin.Interfaces.IRestService], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> No constructors on type 'Eela.Taxi.Service.RestService' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'. (See inner exception for details.)
1
ReflectionActivator.ActivateInstance (Autofac.IComponentContext context, System.Collections.Generic.IEnumerable`1[T] parameters)
2
InstanceLookup.Activate (System.Collections.Generic.IEnumerable`1[T] parameters)
An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = RestService (ReflectionActivator), Services = [Eela.Model.Xamarin.Interfaces.IRestService], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> No constructors on type 'Eela.Taxi.Service.RestService' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'. (See inner exception for details.)
1
InstanceLookup.Activate (System.Collections.Generic.IEnumerable`1[T] parameters)
2
InstanceLookup.Execute ()
3
ResolveOperation.GetOrCreateInstance (Autofac.Core.ISharingLifetimeScope currentOperationScope, Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable`1[T] parameters)
4
ResolveOperation.ResolveComponent (Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable`1[T] parameters)
5
ResolveOperation.Execute (Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable`1[T] parameters)
6
LifetimeScope.ResolveComponent (Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable`1[T] parameters)
7
Container.ResolveComponent (Autofac.Core.IComponentRegistration registration, System.Collections.Generic.IEnumerable`1[T] parameters)
8
ResolutionExtensions.TryResolveService (Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable`1[T] parameters, System.Object& instance)
9
ResolutionExtensions.ResolveService (Autofac.IComponentContext context, Autofac.Core.Service service, System.Collections.Generic.IEnumerable`1[T] parameters)
10
ResolutionExtensions.Resolve (Autofac.IComponentContext context, System.Type serviceType, System.Collections.Generic.IEnumerable`1[T] parameters)
11
ResolutionExtensions.Resolve[TService] (Autofac.IComponentContext context, System.Collections.Generic.IEnumerable`1[T] parameters)
12
ResolutionExtensions.Resolve[TService] (Autofac.IComponentContext context)
13
App+<OnStart>d__4.MoveNext ()
14
ExceptionDispatchInfo.Throw ()
15
AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state)
16
SyncContext+<>c__DisplayClass2_0.<Post>b__0 ()
17
Thread+RunnableImplementor.Run ()
18
IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
19
(wrapper dynamic-method) System.Object:f9684b08-49ee-4f47-8b7c-c59b675c18f3 (intptr,intptr)
So as your Stack Trace indicates. Autofac is trying to instantiate an instance of Eela.Taxi.Service.RestService. However, it seems like the Mono Linker has removed the constructor because it is never directly invoked.
So you could do a couple of things. You could:
Add your assembly to be ignored from the linker
You could add a [Preserve] attribute on your RestService to tell the Linker not to touch it
You could similar to what MvvmCross does have a LinkerPleaseInclude.cs file which describes usage of each type that get stripped out. So for every one you discover you will need to add it here.
So 1. and 2. are fairly self explanatory. You have already used 1. for autofac, just do the same for your own assembly containing RestService. However, the downside here is that nothing in this assembly will be linked, potentially leaving you with a lot more code in it than actually needed.
For 2. you simply add [Preserve] right before declaring your class. So something like:
[Preserve]
public class RestService : IRestService { }
You may also consider using it with AllMembers = true: [Preserve(AllMembers = true)] to keep member fields too.
As for the last option. You basically create a LinkerPleaseInclude.cs in your App project. You let the linker do its job. You continue adding stuff to the class until the Linker does kill your App at runtime. So a start on LinkerPleaseInclude.cs could look like:
[Preserve(AllMembers = true)]
public class LinkerPleaseInclude
{
public void Include(IRestService service)
{
service = new RestService();
}
}
This class is never invoked, but it is enough for the linker to know that the constructor of RestService should not be linked out.
I am using Watin system in my program.
I get the following error:
ArgumentNullException at Watin.Core.Comparer
StringComparer(string comparisonValue, bool ignoreCase)
Error : Value Cannot be Null(comparisonValue)
But I have no idea that who and when stringcomparer is called,
also I don't know how to debug it.
Here is some of my code.
using (IE browser = new IE(url))
{
Trace.TraceInformation("success to create IE instance.");
int waitSecond = TimeSpan.FromSeconds(30).Seconds;
browser.WaitForComplete(waitSecond);
.........
.........
}
)
Add some ErrorTrace
at WatiN.Core.Comparers.StringComparer..ctor(String comparisonValue, Boolean ignoreCase)
at WitiN.core.DialogHandlers.DialogWatcher.HasDialogSameProcessNameAsBrowserWindow(Window window)
at WatiN.Core.DialogHandlers.DialogWatcher.HandleWindow(Window window)
at WatiN.Core.DialogHandlers.DialogWatcher.Start()
at System.Threading.ThreadHelper.ThreadStart_Context(ojbect state)
at System.Threading.ExecutionContext.Runinternal(exceutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutinoContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutinoContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
This code works as expected (no exceptions thrown):
using (IE browser = new IE("http://www.google.com"))
{
//Trace.TraceInformation("success to create IE instance.");
int waitSecond = TimeSpan.FromSeconds(30).Seconds;
browser.WaitForComplete(waitSecond);
}
Make sure you are using the latest sources for WatiN and you don't have any other code executing at that time (the exception you are getting if for a DialogWatcher, nothing to do with the code you posted).
Not sure why you've used the .WaitForComplete method like that but that method is called by default internally for each method you run that interacts with a web page. If you want to specify a generic wait time for loading web pages you should use settings for the WatiN object like this:
Settings.WaitForCompleteTimeOut = 30;
using (IE browser = new IE("http://www.google.com"))
{
//Trace.TraceInformation("success to create IE instance.");
browser.WaitForComplete();
}
I have a RadGrid which is populated with some data. I have a button which will Export to Excel via a serverside callback. The server side code is below. And the error below that. Any suggestions?
RadGrid1.Rebind();
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.MasterTableView.ExportToExcel();
The error is:
The query results cannot be enumerated more than once.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The query results cannot be enumerated more than once.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The query results cannot be enumerated more than once.]
System.Data.Linq.SqlClient.OneTimeEnumerable1.GetEnumerator() +884205
System.Data.Linq.SqlClient.SingleResult1.GetEnumerator() +76
System.Linq.Buffer1..ctor(IEnumerable1 source) +302
System.Linq.d__0.MoveNext() +164
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +163
Telerik.Web.UI.GridResolveEnumerable.GetCollectionItemType(Boolean noItemsInEnumerator, Type& collectionItemType, Object& collectionFirstObject) +330
Telerik.Web.UI.GridResolveEnumerable.ParseProperties() +120
Telerik.Web.UI.GridResolveEnumerable.Initialize() +16
Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +28
Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +242
Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +223
Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +595
Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +243
Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +42
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +72
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +147
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +261
Telerik.Web.UI.GridTableView.PerformSelect() +9
Telerik.Web.UI.GridTableView.DataBind() +363
Telerik.Web.UI.RadGrid.DataBind() +73
Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +2488
Telerik.Web.UI.RadGrid.RebindForExport() +119
Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExport() +315
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnPreRender(EventArgs e) +11056782
System.Web.UI.Control.PreRenderRecursiveInternal() +108
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394
You don't want to call Rebind() before the export. Is there a reason for that? Are you changing/manipulating the data right before the export?
If not, there is no need to call Rebind(), since that is really only meant to refresh the data source.
I am getting Server Error in '/' Application.
Exception Details:
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection. Parameter name:
index
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) +67
System.ThrowHelper.ThrowArgumentOutOfRangeException() +16
System.Collections.Generic.List`1.get_Item(Int32 index) +19
Telerik.Reporting.HtmlRendering.HtmlElementRenderer.GetEndElement(ProcessingElement startElement) +267
Telerik.Reporting.HtmlRendering.HtmlElementRenderer.BeginRender(HtmlRenderingContext context) +382
Telerik.Reporting.HtmlRendering.BaseElementRenderer.RenderToHtml(HtmlRenderingContext context) +17
Telerik.Reporting.HtmlRendering.ContainerElementRenderer.Render(HtmlRenderingContext context) +108
Telerik.Reporting.HtmlRendering.BaseElementRenderer.RenderToHtml(HtmlRenderingContext context) +26
Telerik.Reporting.HtmlRendering.ContainerElementRenderer.Render(HtmlRenderingContext context) +108
Telerik.Reporting.HtmlRendering.BaseElementRenderer.RenderToHtml(HtmlRenderingContext context) +26
Telerik.Reporting.HtmlRendering.ContainerElementRenderer.Render(HtmlRenderingContext context) +108
Telerik.Reporting.HtmlRendering.BaseElementRenderer.RenderToHtml(HtmlRenderingContext context) +26
Telerik.Reporting.HtmlRendering.ContainerElementRenderer.Render(HtmlRenderingContext context) +108
Telerik.Reporting.HtmlRendering.BaseElementRenderer.RenderToHtml(HtmlRenderingContext context) +26
Telerik.Reporting.HtmlRendering.ContainerElementRenderer.Render(HtmlRenderingContext context) +108
Telerik.Reporting.HtmlRendering.BaseElementRenderer.RenderToHtml(HtmlRenderingContext context) +26
Telerik.Reporting.HtmlRendering.ContainerElementRenderer.Render(HtmlRenderingContext context) +108
Telerik.Reporting.HtmlRendering.BaseElementRenderer.RenderToHtml(HtmlRenderingContext context) +26
Telerik.Reporting.HtmlRendering.HtmlTextBoxRenderer.RenderInternal(ProcessingElement processingElement, HtmlRenderingContext context) +163
Telerik.Reporting.HtmlRendering.HtmlItemRender.Telerik.Reporting.HtmlRendering.IReportItemRender.Render(ProcessingElement processingElement, RenderingContext context) +92
Telerik.Reporting.HtmlRendering.RenderingContext.Render(ReportItemBase item) +50
Telerik.Reporting.HtmlRendering.Matrix.RenderInternal(HtmlRenderingContext context) +3645
Telerik.Reporting.HtmlRendering.Matrix.Render(HtmlRenderingContext context) +40
Telerik.Reporting.HtmlRendering.ReportSectionBaseRenderer.RenderInternal(ProcessingElement processingElement, HtmlRenderingContext context) +69
Telerik.Reporting.HtmlRendering.HtmlItemRender.Telerik.Reporting.HtmlRendering.IReportItemRender.Render(ProcessingElement processingElement, RenderingContext context) +92
Telerik.Reporting.HtmlRendering.RenderingContext.Render(ReportItemBase item) +50
Telerik.Reporting.HtmlRendering.HtmlPage.RenderReportSections(HtmlWriter bodyWriter) +557
Telerik.Reporting.HtmlRendering.HtmlPage.RenderBody(HtmlWriter bodyWriter) +320
Telerik.Reporting.HtmlRendering.HtmlPage.Render(HtmlTextWriter primaryWriter, HtmlRenderingContext renderingContext) +112
Telerik.Reporting.HtmlRendering.HtmlReport.Render(HtmlTextWriter writer, Int32 startPage, Int32 endPage) +304
Telerik.Reporting.HtmlRendering.HtmlReport.Render(HtmlTextWriter writer) +56
Telerik.Reporting.HtmlRendering.HtmlRenderingExtension.Telerik.Reporting.Processing.IRenderingExtension.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback) +134
Telerik.Reporting.Processing.ReportProcessor.Render(IList`1 reports, ExtensionInfo extensionInfo, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback) +352
Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, CreateStream createStreamCallback, String& documentName) +421
Telerik.ReportViewer.WebForms.ServerReport.Render(HttpResponse response, String format, Int32 pageIndex) in c:\Projects\Reporting\FromSC_scrum\#ReportingBuild\Reporting_Build\Net20\Telerik.ReportViewer.WebForms\ServerReport.cs:90
Telerik.ReportViewer.WebForms.ReportPageOperation.PerformOperation(NameValueCollection urlQuery, HttpContext context) in c:\Projects\Reporting\FromSC_scrum\#ReportingBuild\Reporting_Build\Net20\Telerik.ReportViewer.WebForms\ReportPageOperation.cs:25
Telerik.ReportViewer.WebForms.HttpHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) in c:\Projects\Reporting\FromSC_scrum\#ReportingBuild\Reporting_Build\Net20\Telerik.ReportViewer.WebForms\HttpHandler.cs:59
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +705
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137
I am getting this error in Telerik Report viewer.
Getting this error only for specific criteria not for all the values.
where i am missing something?
Please help me.
I have same problem. I didn't figured out its origin yet, but I suppose it comes from data source binding. When you create new instance on report it creates default controls in InitializeComponent() method (for example, List with 0 rows or TextBox without text). And when you bind data source (for example, List with 3 items) it refer to List (Telerik Reporting control) and try to bind collection with 3 items to control with 0 rows. So in this case you had OutOfRangeException. Something like that, I guess.
UPD: actually, I had resolved my problem yesterday. It was all because I try to bind empty collection as control's data source. I just added default object (with empty properties) to my collection if it contains no elements before binding.
We have been experiencing a very similar issue intermittently. Clearing out the Telerik state database tables seems to resolve it sometimes for us. You can flip #Condition to 1 in the script below to execute the delete.
DECLARE #Condition AS BIT = 0;
IF #Condition = 1
BEGIN
DELETE dbo.tr_AppLock;
DELETE dbo.tr_Object;
DELETE dbo.tr_Set;
DELETE dbo.tr_String;
END;
SELECT *
FROM dbo.tr_AppLock AS tal;
SELECT *
FROM dbo.tr_Object AS tob;
SELECT *
FROM dbo.tr_Set AS ts;
SELECT *
FROM dbo.tr_String AS ts;
Check that you can preview the report in the Telerik Report Designer.
I was seeing the same error when running code:
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection. Parameter name:
index
In the report designer I had the error:
Missing or invalid parameter value. Please input valid data for all
parameters
I corrected the Report Designer error (by adding a default parameter value, see screenshot below) and made no other 'code' changes, this resolved both issues.
Interestingly if I remove the default value the Report Designer error returns but running the report in code remains OK (possibly the report is cached somewhere in a valid state?)
Is there any way of doing this at all? I have a string field in the DB and I want to parse it into a int property in my LINQ query (yes, it must be at the IQueryable level, not in memory).
I know 2 years ago EF 1.0 couldn't do this (even though LINQ to SQL supported this basic functionality out of the box)...but I'm just wondering if anyone has come up with a way of doing this at this point?
Custom function mappings? Special syntax? Anything at all....
UPDATE:
I tried a model defined function as follows:
<Function Name="ConvertToInt32" ReturnType="Edm.Int32">
<Parameter Name="v" Type="Edm.String" />
<DefiningExpression>
CAST(v AS INT)
</DefiningExpression>
</Function>
[EdmFunction("Model.Repository", "ConvertToInt32")]
public static int ConvertToInt32(string value)
{
throw new InvalidOperationException("Only valid when used as part of a LINQ query.");
}
but it doesn't seem to work. I get the runtime exception:
ErrorDescription=Type 'INT' could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly.
StackTrace:
at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertTypeName(Node typeName, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertTypeExprArgs(BuiltInExpr astBuiltInExpr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.<CreateBuiltInExprConverter>b__73(BuiltInExpr bltInExpr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertBuiltIn(Node astExpr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.Convert(Node astExpr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertValueExpression(Node astExpr, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.ConvertQueryStatementToDbExpression(Statement astStatement, SemanticResolver sr)
at System.Data.Common.EntitySql.SemanticAnalyzer.AnalyzeQueryCommand(Node astExpr)
at System.Data.Common.EntitySql.CqlQuery.<AnalyzeQueryExpressionSemantics>b__8(SemanticAnalyzer analyzer, Node astExpr)
at System.Data.Common.EntitySql.CqlQuery.AnalyzeSemanticsCommon[TResult](Node astExpr, Perspective perspective, ParserOptions parserOptions, IEnumerable`1 parameters, IEnumerable`1 variables, Func`3 analysisFunction)
at System.Data.Common.EntitySql.CqlQuery.AnalyzeQueryExpressionSemantics(Node astQueryCommand, Perspective perspective, ParserOptions parserOptions, IEnumerable`1 parameters, IEnumerable`1 variables)
at System.Data.Common.EntitySql.CqlQuery.<>c__DisplayClass4.<CompileQueryCommandLambda>b__3(Node astCommand, ParserOptions validatedParserOptions)
at System.Data.Common.EntitySql.CqlQuery.CompileCommon[TResult](String commandText, Perspective perspective, ParserOptions parserOptions, Func`3 compilationFunction)
at System.Data.Common.EntitySql.CqlQuery.CompileQueryCommandLambda(String queryCommandText, Perspective perspective, ParserOptions parserOptions, IEnumerable`1 parameters, IEnumerable`1 variables)
at System.Data.Mapping.ViewGeneration.Utils.ExternalCalls.CompileFunctionDefinition(String functionFullName, String functionDefinition, IList`1 functionParameters, EdmItemCollection edmItemCollection)
at System.Data.Metadata.Edm.EdmItemCollection.GenerateFunctionDefinition(EdmFunction function)
at System.Data.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()
at System.Data.Common.Utils.Memoizer`2.Result.GetValue()
at System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg)
at System.Data.Metadata.Edm.EdmItemCollection.GetGeneratedFunctionDefinition(EdmFunction function)
at System.Data.Metadata.Edm.MetadataWorkspace.GetGeneratedFunctionDefinition(EdmFunction function)
at System.Data.Query.PlanCompiler.ITreeGenerator.Visit(DbFunctionExpression e)
InnerException:
UPDATE: I got it to work as follows
<Function Name="ConvertToInt32" ReturnType="Edm.Int32">
<Parameter Name="v" Type="Edm.String" />
<DefiningExpression>
CAST(v AS Edm.Int32)
</DefiningExpression>
</Function>
If you are using EFv4 + EDMX you can create custom model defined function which will do the CAST for you. You can then use that function in Linq-to-entities queries.