System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at DevExpress.Blazor.DxLayoutBreakpoint.get_DeviceSize()
at InvokeStub_DxLayoutBreakpoint.get_DeviceSize(Object, Object, IntPtr*)
What is the initial value of IsRadzen? It should be true in order for this to work. Radzen Blazor Studio does not execute any code put in OnInitializeAsync.
No it doesn't. Something is very strange in your case. You should definitely see the content in the if statement even without the #if !RADZEN statement.
Unfortunately I can't build this project due to the following error:
Unable to find package DevExpress.Blazor. No packages exist with this id in source(s): /usr/local/share/dotnet/library-packs, nuget.org, Package source 1
This is known to happen with packages that don't exist in nuget.org. Let's try to reproduce the other problem that you don't see the div element in design time. What version of RBS are you using?
The Div should be hidden in Design Time and it is.
I was trying to show that DxLayoutBreakpoint is still seen and Radzen tries to process it, hence the error.
Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at DevExpress.Blazor.DxLayoutBreakpoint.get_DeviceSize()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void* arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr args, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.PropertyInfo.GetValue(Object obj)
at Radzen.Server.Reflector.<>c__DisplayClass16_0.b__0() in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 171
at Radzen.Server.ConcurrentDictionaryExtensions.GetValue[T,U](ConcurrentDictionary2 dictionary, T key, Func1 factory) in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 18
at Radzen.Server.Reflector.GetPropertyValue(Object instance, PropertyInfo property) in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 171
at Radzen.Server.Visitor.WritePropertyInfo(String assemblyName, String typeName, PropertyInfo property, Object instance, IDictionary2 typeArguments, Boolean children) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 477 at Radzen.Server.Visitor.VisitComponent(ComponentIntermediateNode node) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 807 at Microsoft.AspNetCore.Razor.Language.Intermediate.ComponentIntermediateNode.Accept(IntermediateNodeVisitor visitor) at Radzen.Server.Visitor.Serialize(Func2 infer, Reflector reflector, IntermediateNode node, String source, Stack1 path, ISet1 visited) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 1164
at Radzen.Server.InjectMetadataFeature.Serialize(IntermediateNode parent, IntermediateNodeReference node, String source, IDictionary2 json, ISet1 visited) in /Users/korchev/github/radzen-next/Radzen.Server/InjectMetadata.cs:line 209
at Radzen.Server.InjectMetadataFeature.ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) in /Users/korchev/github/radzen-next/Radzen.Server/InjectMetadata.cs:line 82
at Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase.Execute(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
at Microsoft.AspNetCore.Razor.Language.DefaultRazorOptimizationPhase.ExecuteCore(RazorCodeDocument codeDocument)
at Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument)
at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
at Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.ProcessCore(RazorCodeDocument codeDocument)
at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem)
at Radzen.Server.ProjectContext.ProcessFile(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectContext.cs:line 235
at Radzen.Server.ProjectServer.ProcessFile(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 831
at Radzen.Server.ProjectServer.ParseDocument(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime, Boolean prepare) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 968
at Radzen.Server.ProjectServer.Compile(String fileName, String source, RazorProjectEngine projectEngine) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 1317
at Radzen.Server.ProjectServer.CompilePage(String fileName, String source, RazorProjectEngine engine) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 660
at Radzen.Server.ProjectServer.Render(String fileName, String source) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 906
at Radzen.Server.ProgramController.Render(RenderRequest request) in /Users/korchev/github/radzen-next/Radzen.Server/ProgramController.cs:line 455
It seems to happen with other DevExpress components as well
This causes the error below:
<DxTextBox @bind-Text="@Email" />
Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at DevExpress.Blazor.DxTextBox.get_Password()
at InvokeStub_DxTextBox.get_Password(Object, Object, IntPtr)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr args, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Radzen.Server.Reflector.<>c__DisplayClass16_0.b__0() in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 171
at Radzen.Server.Reflector.GetPropertyValue(Object instance, PropertyInfo property) in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 171
at Radzen.Server.Visitor.WritePropertyInfo(String assemblyName, String typeName, PropertyInfo property, Object instance, IDictionary2 typeArguments, Boolean children) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 526 at Radzen.Server.Visitor.VisitComponent(ComponentIntermediateNode node) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 924 at Radzen.Server.Visitor.Serialize(Func2 infer, Reflector reflector, IntermediateNode node, String source, Stack1 path, ISet1 visited) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 1168
at Radzen.Server.InjectMetadataFeature.ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) in /Users/korchev/github/radzen-next/Radzen.Server/InjectMetadata.cs:line 198
at Microsoft.AspNetCore.Razor.Language.DefaultRazorOptimizationPhase.ExecuteCore(RazorCodeDocument codeDocument)
at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem)
at Radzen.Server.ProjectContext.ProcessFile(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectContext.cs:line 237
at Radzen.Server.ProjectServer.ParseDocument(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime, Boolean prepare) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 991
at Radzen.Server.ProjectServer.Compile(String fileName, String source, RazorProjectEngine projectEngine) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 1359
at Radzen.Server.ProjectServer.CompilePage(String fileName, String source, RazorProjectEngine engine) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 661
at Radzen.Server.ProjectServer.Render(String fileName, String source) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 927
at Radzen.Server.ProgramController.Render(RenderRequest request) in /Users/korchev/github/radzen-next/Radzen.Server/ProgramController.cs:line 463
Indeed. It is hard to tell why DevExpress components don't work without checking their implementation. Unfortunately we can't do anything on this issue as DevExpress are closed source. Will leave this issue open in case there is any further development.
I reached out to DevExpress and this is the response I received:
As I understand from the call-stack, Radzen's code gets the value from the Rows property of DxMemo. If this code is performxecuted before the internal model of DxMemo is created, this exception is expected.
It's not clear to me why Radzen's code doing ithis and how it can be prevented. I recommend that you contact Radzen's support regaboutrding this behavior of Radzen Blazor Studion.
I would like to note that we officially support only VS Code and Visual Studio IDEs:
We cannot guarantee the correct work of our components in other IDEs.
Today we release RBS 1.2.0 which improves the behavior when a component fails to render. Now failed components will not prevent the entire page to display. This still does not fix the compatibility issue with DevExpress but should improve the experience.
I am closing this issue since we can't further investigate what is causing the DevExpress compatibility issue. So far we have found they are using non-standard way to do dependency injection which isn't compatible with what Radzen Blazor Studio is doing.
I get the error below when I use DevExpress <DxLayoutBreakpoint MaxWidth="779" @bind-IsActive="@isXSmallScreen" />
I tried using code below to hide when not in Radzen but I still get the error, if I just have a
I also have this in cs file:
public bool IsRazden = true;
protected override async System.Threading.Tasks.Task OnInitializedAsync() {
}
@if(IsRazden == false) {
<DxLayoutBreakpoint MaxWidth="779" @bind-IsActive="@isXSmallScreen" />
}
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DevExpress.Blazor.DxLayoutBreakpoint.get_DeviceSize() at InvokeStub_DxLayoutBreakpoint.get_DeviceSize(Object, Object, IntPtr*)
Sorry the "Div>" was taken out in my previous message
What is the initial value of
IsRadzen
? It should be true in order for this to work. Radzen Blazor Studio does not execute any code put inOnInitializeAsync
.I set it to
public bool IsRazden = true;
Do you see the test div in design mode if you remove the breakpoint component?
The "Div" only show when I run the app, it is hidden in Blazor Studio
This is strange. Here is how it looks when I test it:
Does it show when you run the app?
No it doesn't. Something is very strange in your case. You should definitely see the content in the if statement even without the
#if !RADZEN
statement.Can you send us your application so we can try? Send a link to info@radzen.com.
DxGridLayoutAdaptivity.Server.zip
this one from Github gives the same error
Unfortunately I can't build this project due to the following error:
This is known to happen with packages that don't exist in nuget.org. Let's try to reproduce the other problem that you don't see the div element in design time. What version of RBS are you using?
The div element is not an error (it should not show up in design time) in the .cs file I have the following:
public static bool IsRazden = true;
protected override async System.Threading.Tasks.Task OnInitializedAsync() {
and in the .razor file I have:
@if(IsRazden ==false) {
<DxLayoutBreakpoint DeviceSize="DeviceSize.XSmall" @bind-IsActive="@isXSmallScreen" />
The Div should be hidden in Design Time and it is. I was trying to show that DxLayoutBreakpoint is still seen and Radzen tries to process it, hence the error.
You will also need to download a trial version of DevExpress components for Blazor to compile and run the sample project.
Can you try with a non static field - just
public bool IsRadzen = true
.I am afraid I can't do that due to company policy.
public bool IsRadzen = true.
Still the same
Here is a sample application that works as expected - content does not show in design time but shows at runtime.
PreProcessorConditions.zip
Still the same issue using your sample application
I added the DXLayoutBreakpoint to the index.razor and still get the error below @if (!IsRadzen) {
}
Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DevExpress.Blazor.DxLayoutBreakpoint.get_DeviceSize() at System.RuntimeMethodHandle.InvokeMethod(Object target, Void* arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr args, BindingFlags invokeAttr) --- End of inner exception stack trace --- at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.PropertyInfo.GetValue(Object obj) at Radzen.Server.Reflector.<>c__DisplayClass16_0.b__0() in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 171
at Radzen.Server.ConcurrentDictionaryExtensions.GetValue[T,U](ConcurrentDictionary
2 dictionary, T key, Func
1 factory) in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 18 at Radzen.Server.Reflector.GetPropertyValue(Object instance, PropertyInfo property) in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 171 at Radzen.Server.Visitor.WritePropertyInfo(String assemblyName, String typeName, PropertyInfo property, Object instance, IDictionary2 typeArguments, Boolean children) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 477 at Radzen.Server.Visitor.VisitComponent(ComponentIntermediateNode node) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 807 at Microsoft.AspNetCore.Razor.Language.Intermediate.ComponentIntermediateNode.Accept(IntermediateNodeVisitor visitor) at Radzen.Server.Visitor.Serialize(Func
2 infer, Reflector reflector, IntermediateNode node, String source, Stack1 path, ISet
1 visited) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 1164 at Radzen.Server.InjectMetadataFeature.Serialize(IntermediateNode parent, IntermediateNodeReference node, String source, IDictionary2 json, ISet
1 visited) in /Users/korchev/github/radzen-next/Radzen.Server/InjectMetadata.cs:line 209 at Radzen.Server.InjectMetadataFeature.ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) in /Users/korchev/github/radzen-next/Radzen.Server/InjectMetadata.cs:line 82 at Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase.Execute(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) at Microsoft.AspNetCore.Razor.Language.DefaultRazorOptimizationPhase.ExecuteCore(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document) at Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.ProcessCore(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem) at Radzen.Server.ProjectContext.ProcessFile(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectContext.cs:line 235 at Radzen.Server.ProjectServer.ProcessFile(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 831 at Radzen.Server.ProjectServer.ParseDocument(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime, Boolean prepare) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 968 at Radzen.Server.ProjectServer.Compile(String fileName, String source, RazorProjectEngine projectEngine) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 1317 at Radzen.Server.ProjectServer.CompilePage(String fileName, String source, RazorProjectEngine engine) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 660 at Radzen.Server.ProjectServer.Render(String fileName, String source) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 906 at Radzen.Server.ProgramController.Render(RenderRequest request) in /Users/korchev/github/radzen-next/Radzen.Server/ProgramController.cs:line 455It seems to happen with other DevExpress components as well This causes the error below:
<DxTextBox @bind-Text="@Email" />
Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DevExpress.Blazor.DxTextBox.get_Password() at InvokeStub_DxTextBox.get_Password(Object, Object, IntPtr) at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr args, BindingFlags invokeAttr) --- End of inner exception stack trace --- at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Radzen.Server.Reflector.<>c__DisplayClass16_0.b__0() in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 171
at Radzen.Server.Reflector.GetPropertyValue(Object instance, PropertyInfo property) in /Users/korchev/github/radzen-next/Radzen.Server/Reflector.cs:line 171
at Radzen.Server.Visitor.WritePropertyInfo(String assemblyName, String typeName, PropertyInfo property, Object instance, IDictionary
2 typeArguments, Boolean children) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 526 at Radzen.Server.Visitor.VisitComponent(ComponentIntermediateNode node) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 924 at Radzen.Server.Visitor.Serialize(Func
2 infer, Reflector reflector, IntermediateNode node, String source, Stack1 path, ISet
1 visited) in /Users/korchev/github/radzen-next/Radzen.Server/Visitors.cs:line 1168 at Radzen.Server.InjectMetadataFeature.ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) in /Users/korchev/github/radzen-next/Radzen.Server/InjectMetadata.cs:line 198 at Microsoft.AspNetCore.Razor.Language.DefaultRazorOptimizationPhase.ExecuteCore(RazorCodeDocument codeDocument) at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document) at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem) at Radzen.Server.ProjectContext.ProcessFile(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectContext.cs:line 237 at Radzen.Server.ProjectServer.ParseDocument(String fileName, String source, RazorProjectEngine projectEngine, Boolean designTime, Boolean prepare) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 991 at Radzen.Server.ProjectServer.Compile(String fileName, String source, RazorProjectEngine projectEngine) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 1359 at Radzen.Server.ProjectServer.CompilePage(String fileName, String source, RazorProjectEngine engine) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 661 at Radzen.Server.ProjectServer.Render(String fileName, String source) in /Users/korchev/github/radzen-next/Radzen.Server/ProjectServer.cs:line 927 at Radzen.Server.ProgramController.Render(RenderRequest request) in /Users/korchev/github/radzen-next/Radzen.Server/ProgramController.cs:line 463Indeed. It is hard to tell why DevExpress components don't work without checking their implementation. Unfortunately we can't do anything on this issue as DevExpress are closed source. Will leave this issue open in case there is any further development.
Thanks for your efforts!
I reached out to DevExpress and this is the response I received:
As I understand from the call-stack, Radzen's code gets the value from the Rows property of DxMemo. If this code is performxecuted before the internal model of DxMemo is created, this exception is expected. It's not clear to me why Radzen's code doing ithis and how it can be prevented. I recommend that you contact Radzen's support regaboutrding this behavior of Radzen Blazor Studion. I would like to note that we officially support only VS Code and Visual Studio IDEs: We cannot guarantee the correct work of our components in other IDEs.
Today we release RBS 1.2.0 which improves the behavior when a component fails to render. Now failed components will not prevent the entire page to display. This still does not fix the compatibility issue with DevExpress but should improve the experience.
I am closing this issue since we can't further investigate what is causing the DevExpress compatibility issue. So far we have found they are using non-standard way to do dependency injection which isn't compatible with what Radzen Blazor Studio is doing.