InvokeOperation<bool> value always false - silverlight

Quick question about the InvokeOperation, so from my view model i have this...
private void IsValidNumber(string value)
{
_context.NumberIsValid(value, ValidNumberCallback, null);
}
private void ValidNumberCallback(InvokeOperation<bool> obj)
{
var test = obj.Value; //ALWAYS FALSE????
}
and in my domainSerice class i have this.
[Invoke]
public bool NumberIsValid(string number)
{
return true;
}
and the call back value is always false??? what am I missing???
any help or pointers would be greatly appreciated

You should check for HasError property.
If for any reason connection to your http server fails, method callback will be called but with HasError as true and you will get details of the error in Error object.

welp... I decided to just hurry and build a simple test site and it works just peachy... I think it might have to do with something in my webconfig... if I ever find the real issue I'll update this.
<compilation debug="true" targetFramework="4.0">
<assemblies>
<remove assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /></assemblies>
</compilation>
the assemblies seems to have been the issue, I removed that section and it started working again... why?? no clue

Related

Merge issue with Collection(Edm.Double) field: Cannot convert the literal '0.73' to the expected type 'Edm.String'

I have a column defined in Azure Search index as follows:
{
"name": "agreedValues",
"type": "Collection(Edm.Double)",
"facetable": false,
"filterable": false,
"retrievable": true,
"analyzer": null,
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
},
and am running a netcoreapp2.1 Azure Function (v2) with nuget Microsoft.Azure.Search 10.1.0
It works to add documents to the index using a document DTO with corresponding property
public ImmutableList<double> AgreedValues { get; }
(and attribute [SerializePropertyNamesAsCamelCase] on DTO class to fix case issues)
but when I try to merge updates to document the Search API responds with
The request is invalid. Details: parameters : Cannot convert the literal '0.73' to the expected type 'Edm.String'.
from
Microsoft.Rest.Azure.CloudException:
at Microsoft.Azure.Search.DocumentsProxyOperations+<IndexWithHttpMessagesAsync>d__13`1.MoveNext (Microsoft.Azure.Search.Data, Version=10.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.Search.DocumentsOperations+<DoIndexAsync>d__19`1.MoveNext (Microsoft.Azure.Search.Data, Version=10.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.Search.DocumentsOperationsExtensions+<IndexAsync>d__15`1.MoveNext (Microsoft.Azure.Search.Data, Version=10.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
Any ideas/suggestions to resolve are welcome.
I wasn’t able to reproduce this error - could you please share an index definition & index/query request that fails?

Can't insert into SQL Server table with log4net AdoNetAppender

I am trying to understand how log4net works so I've added this to my app.config (I should add that Console Appender and FileAppender work perfectly, I only have trouble with the AdoNetAppender).
How can I debug this, to see if at least the connection to db succeeds?
The problem is the INSERT statement isn't executed.
I should add the
Data Source=MyWorkgroup\SQLEXPRESS;Initial Catalog=MyNewDatabase;User ID=juan;password=juan,
works perfectly when I try to connect to SQL Server manually, so not sure if that's the problem.
Also, the ConnectionType was taken from the official site:
https://logging.apache.org/log4net/log4net-1.2.11/release/sdk/log4net.Appender.AdoNetAppender.ConnectionType.html
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.log4netConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<appender name="AdoNetAppender"
type="log4net.Appender.AdoNetAppender">
<bufferSize value="10" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="Data Source=MyWorkgroup\SQLEXPRESS;Initial Catalog=MyNewDatabase;User ID=juan;Password=juan;Pooling=False" />
<commandText value="INSERT INTO Logs([logDate],[logThread],[logMessage]) VALUES(getdate(),'1','1')" />
<commandType value="Text" />
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="AdoNetAppender"/>
</root>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Later edit (after using the debug method recommended by David):
haacked.com is indeed extremely interesting, great tip! However, it seems that it's describing what I'm instructing log4net to log, but not the result of those actions(?), if I'm reading this well (no failed/or succeeded?)
e.g.
log4net: Setting Property [ConnectionType] to String value
[System.Data.SqlClien t.SqlConnection, System.Data,
Version=1.0.3300.0, Culture=neutral, PublicKeyToke n=b77a5c561934e089]
log4net: Setting Property [ConnectionString] to String value [Data
Source=MyWorkgroup\SQLEXPRESS; Initial
Catalog=MyNewDatabase;
User ID=juan; Password=juan;
Pooling=False] log4net: Setting Property [CommandText] to String value [INSERT INTO Logs([logDate],[logThread],[logMessage]) VALUES(getdate(),'1','1')] log4net:
Setting Property [CommandType] to CommandType value [Text] log4net:
Created Appender [AdoNetAppender] log4net: Adding appender named
[AdoNetAppender] to logger [root]. log4net: Hierarchy Threshold []
Piece of code that helped me obtain this info (in case the site should become unavailable) is:
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\temp\log4netdiagn.txt" />
</listeners>
</trace>
</system.diagnostics>

How can i rename the log file with Modified date by using Rolling Flat File Trace Listener

My desire output is, if "rolling.log" file was created and modified by 26-06-2012, next day(27-06-2012) that file should be renamed with "rolling-26-06-2012..log". Now output is "rolling-27-06-2012.log" file.
Below is my current logging setting in web.config file.
<*loggingConfiguration name="" tracingEnabled="true" defaultCategory="myTestLog">
<*listeners>
<*add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\Project\Others\Testing\testMSLogging\rolling.log"
formatter="Text Formatter" rollFileExistsBehavior="Increment"
rollInterval="Minute" rollSizeKB="50" timeStampPattern="yyMMdd"
filter="Information" />
<*add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\Project\Others\Testing\testMSLogging\testMSLogging\trace.log"
formatter="Text Formatter" filter="Error" />
</listeners>
<*formatters>
<*add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
</formatters>
<*categorySources>
<*add switchValue="All" name="myTestLog">
<*listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<*specialSources>
<*allEvents switchValue="All" name="All Events" />
<*notProcessed switchValue="All" name="Unprocessed Category" />
<*errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
Please anyone help me. Thanks a lot.
Unfortunately this is the way it works in Enterprise Library. The philosophy behind its default flat file roller is that it records all the output in FILE.LOG and when the roll event happens, it renames it to FILE-ROLL-NAME.LOG and creates a new FILE.LOG
If you need a different behavior, you may need to create your own logging trace listener or use other tools out there like log4net.

Example of Silverlight 5 RIA services authentication with active directory [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm looking for example of Silverlight 5 RIA services with authentication with active directory,
that can be downloaded and that works
Thanks in advance.
I have not found a complete downloadable example. The easiest way is to create a new Silverlight Business Application and then make the following changes to the 3 files specified (Web.config, App.xaml.cs, User.cs):
App.xaml.cs
Comment out (or remove) the following lines:
//webContext.Authentication = new FormsAuthentication();
Uncomment the following lines:
webContext.Authentication = new WindowsAuthentication();
User.cs
add the [ProfileUsage...] statement to the public partial class user so it looks like the following:
public partial class User : UserBase
{
[ProfileUsage(IsExcluded=true)] ///NEEDED FOR WINDOWS/ACTIVE DIRECTORY LOGON
public string FriendlyName { get; set; }
}
Web.config:
Comment out (or remove) the following lines:
<!--<authentication mode="Forms">
<forms name=".AuthenticationTest_ASPXAUTH" timeout="2880" />
</authentication>-->
Uncomment the following lines:
<authentication mode="Windows"/>
Comment out (or remove) the following lines:
<!--<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
<providers>
<clear />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<profile defaultProvider="DefaultProfileProvider">
<properties>
<add name="FriendlyName" />
</properties>
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>-->
<!--<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>-->
Add the following lines:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="winAuthBasicHTTPBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="AuthenticationTest.Web.AuthenticationServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service behaviorConfiguration="AuthenticationTest.Web.AuthenticationServiceBehavior" name="System.Web.ApplicationServices.AuthenticationService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="winAuthBasicHTTPBinding"
contract="System.Web.ApplicationServices.AuthenticationService">
</endpoint>
</service>
</services>
</system.serviceModel>

wpf - Get values from App Config file

How to get values from App.Config.
Code:
<configuration>
<appSettings>
<add key="ShowRoomCode" value="1000"/>
<add key="FolderPath" value="D:\\Images\\Book\\"/>
</appSettings>
</configuration>
string imageFolderPath = ConfigurationManager.AppSettings["FolderPath"];
But it returns null value. Config file is in the Same project.
If you expand the Properties section of Visual Studio and double click the settings section, you will be able to add custom settings which end up like so in the config file:
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="WpfApplication1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<WpfApplication1.Properties.Settings>
<setting name="FilePath" serializeAs="String">
<value>Thing</value>
</setting>
</WpfApplication1.Properties.Settings>
</userSettings>
</configuration>
Which you can then do this in your code:
string thing = Properties.Settings.Default.FilePath;
Which is nice because it gives you type safety too
The code you wrote should work - make sure you haven't changed 'BuildAction' of the config file.

Resources