3
Answers

Why the VisualStudio Closing when i write this Wpf xmal code?

V G S Naidu A

V G S Naidu A

12y
2.9k
1
Hai,
i have written a code in wpf to show the Exponential , by accepting the two numbers
for that i have created one converter function and code..
but when after writing this code it showing error like
"Microsoft Visual Studio encountered a problem and it has to Closed"..then when we click on Don't send it closes the Vs2010.
What might be the problem for that? the code is attached here...
 


namespace WpfTutSamples { /// <summary> /// Interaction logic for Exponential.xaml /// </summary> public partial class Exponential : Window { public Exponential() { InitializeComponent(); } public double GetValue(double number, double exponent) { double value = Math.Pow(number, exponent); return value;   } } }     -----XmlCode   <Window x:Class="WpfTutSamples.Exponential" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfTutSamples" xmlns:sys="clr-namespace:System;assembly=mscorlib" Title="Exponential" Height="300" Width="300"> <Window.Resources> <ObjectDataProvider x:Key="expCalculator" MethodName="GetValue" ObjectType="{x:Type local:Exponential}"> <ObjectDataProvider.MethodParameters> <sys:Double>4</sys:Double> <sys:Double>2</sys:Double> </ObjectDataProvider.MethodParameters> </ObjectDataProvider> </Window.Resources>   <Grid>   <Label Content="Number" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2"> </Label>   <TextBox HorizontalAlignment="Left" x:Name="txtNumber" Height="30" VerticalAlignment="Top" Margin="70,1" Width="60" Text="{Binding Source={StaticResource expCalculator}, Path=MethodParametes[0], Mode=OneWayToSource, BindsDirectlyToSource=True}"></TextBox>   <Label Content="Number" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,40"> </Label> <TextBox HorizontalAlignment="Left" x:Name="txtpower" Height="30" VerticalAlignment="Top" Margin="70,40" Width="60" Text="{Binding Source={StaticResource expCalculator}, Path=MethodParametes[1], Mode=OneWayToSource, BindsDirectlyToSource=True}"></TextBox>   <Label Content="Result" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,80"> </Label> <TextBox HorizontalAlignment="Left" x:Name="txtResult" Height="30" VerticalAlignment="Top" Margin="70,80" Width="60" Text="{Binding Source={StaticResource expCalculator}}"></TextBox>   </Grid> </Window>
Answers (3)
0
Rahul Kaushik
NA 383 14.6k 7y
There is a perfect way while using flag to detect whether someone is already logged in or not and in case if System get power off , you need an event handler called as SystemEvents.SessionEnds.
 
Use this to change the flag value from true to false
 
Use this link as a reference
https://stackoverflow.com/questions/6799955/how-to-detect-windows-shutdown-or-logoff 
0
Mann Maurya
NA 47 867 7y
Hey Ajeesh
 
one more question... ??
 
If power off happen then how you suppose to Reset the flag
 
0
Ajeesh
NA 349 1.6k 7y
You can take a look at this article which discuss a similar topic. 
 
https://blog.learningtree.com/preventing-duplicate-logins-in-asp-net/
 
Another option would be to have a flag in your table and set the value to true when an user login and when user log off set the value to false.  Also for when a second user tries to login we will first check if login flag has been set to true for any other user. If its true then show message to user and display the login page, if not allow the user to login.