Xaml resource style for custom controls - xaml

I have a custom control TextEntry which derives from Edit. I want to apply a style to it, however, the custom xaml namespace and TargetType aren't playing nice. Below is an excerpt which shows the style and different ways i've tried addressing the TargetType issue .
The Resource dictionary - excerpt
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:GRES.App.Forms.CustomControls;assembly=GRES.App.Forms"
x:Class="GRES.App.Forms.CustomControls.GresPage">
<ContentPage.Resources>
<ResourceDictionary>
<!--Entry Styles-->
<Style x:Key="DefaultEntry" TargetType="{controls:TextEntry}">
<!--styles-->
</Style>
</ResourceDictionary>
</ContentPage.Resources>
</ContentPage>
Try one:
TargetType="{controls:TextEntry}"
Result:
System.ArgumentException: Object of type 'GRES.App.Forms.CustomControls.TextEntry' cannot be converted to type 'System.Type'.
Try two:
TargetType="{x:Type controls:TextEntry}"
Result:
System.InvalidOperationException: Sequence contains more than one matching element
Try three:
TargetType="controls:TextEntry"
Result:
System.InvalidOperationException: Sequence contains more than one matching element
StackTrace - TestCase 2 (TestCase 3 produces same stacktrace )
05-04 22:13:46.541 I/MonoDroid(22866): UNHANDLED EXCEPTION:
05-04 22:13:46.541 I/MonoDroid(22866): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Sequence contains more than one matching element
05-04 22:13:46.541 I/MonoDroid(22866): at System.Linq.Enumerable.SingleOrDefault[TSource] (IEnumerable`1 source, System.Func`2 predicate) [0x00098] in /Users/builder/data/lanes/2970/46c3f7e0/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:1105
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.ReflectionExtensions.GetField (System.Type type, System.Func`2 predicate) [0x00006] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.BindablePropertyConverter.ConvertFrom (System.Type type, System.String propertyName, IXmlLineInfo lineinfo) [0x00017] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.BindablePropertyConverter.Xamarin.Forms.IExtendedTypeConverter.ConvertFrom (System.Globalization.CultureInfo culture, System.Object value, IServiceProvider serviceProvider) [0x0013e] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.TypeConversionExtensions.ConvertTo (System.Object value, System.Type toType, System.Func`1 getConverter, IServiceProvider serviceProvider) [0x0003d] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.TypeConversionExtensions.ConvertTo (System.Object value, System.Type toType, System.Func`1 minfoRetriever, IServiceProvider serviceProvider) [0x00021] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue (System.Object xamlelement, XmlName propertyName, System.Object value, Xamarin.Forms.BindableObject rootElement, INode node, Xamarin.Forms.Xaml.HydratationContext context, IXmlLineInfo lineInfo) [0x00357] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit (Xamarin.Forms.Xaml.ValueNode node, INode parentNode) [0x0005e] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.ValueNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00054] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00089] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.FillResourceDictionariesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x00185] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00008] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00089] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x0002f] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.String xaml) [0x000be] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x0002e] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TView] (Xamarin.Forms.Xaml.TView view, System.Type callingType) [0x00000] in <filename unknown>:0
05-04 22:13:46.541 I/MonoDroid(22866): at GRES.App.Forms.CustomControls.GresPage.InitializeComponent () [0x00001] in c:\Git\Gres\GRES.Core\GRES.App.Forms\GRES.App.Forms\obj\Debug\GresPage.xaml.g.cs:21
05-04 22:13:46.541 I/MonoDroid(22866): at GRES.App.Forms.CustomControls.GresPage..ctor () [0x00008] in c:\Git\Gres\GRES.Core\GRES.App.Forms\GRES.App.Forms\CustomControls\GresPage.xaml.cs:18
05-04 22:13:46.541 I/MonoDroid(22866): at GRES.App.Forms.Pages.LoginPage..ctor () [0x00000] in c:\Git\Gres\GRES.Core\GRES.App.Forms\GRES.App.Forms\Pages\LoginPage.xaml.cs:8
05-04 22:13:46.541 I/MonoDroid(22866): at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
05-04 22:13:46.541 I/MonoDroid(22866): at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/2970/46c3f7e0/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644
05-04 22:13:46.541 I/MonoDroid(22866): --- End of inner exception stack trace ---

Related

Getting exceptions like object used after being disposed, NullReference while upload to Amazon.S3

I have a code which reads file in stream and uploads it to amazon S3. I used Amazon .net SDK for Monotouch and Mono for Android which internally where Amazon SDK AssemblyVersion("1.5.2.1")
which is working fine.
But sometimes following exceptions are thrown while upload:
Message = The object was used after being disposed.;
StackTrace = at System.Net.WebConnection.BeginWrite (System.Net.HttpWebRequest request, System.Byte[] buffer, Int32 offset, Int32 size, System.AsyncCallback cb, System.Object state) [0x00000] in <filename unknown>:0
at System.Net.WebConnectionStream.BeginWrite (System.Byte[] buffer, Int32 offset, Int32 size, System.AsyncCallback cb, System.Object state) [0x00000] in <filename unknown>:0
Message = Object reference not set to an instance of an object;
StackTrace = at System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply (System.ServiceModel.Channels.Message message, System.Object[] parameters) [0x00000] in <filename unknown>:0
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x00000] in <filename unknown>:0
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in <filename unknown>:0
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in <filename unknown>:0
I've NOT set file stream = null or dispose for file stream being uploaded any where in code.
Found similar problem explained here
the line where I get exception, it tries to upload the given stream to s3.
More detailed explanation http://forums.xamarin.com/discussion/27098/getting-exceptions-like-object-used-after-being-disposed-nullreference-while-upload-to-amazon-s3
Some more stack traces:
--
UploadUsingHighLevelAPI; Message = Object reference not set to an instance of an object;
StackTrace = at System.Xml.XmlInputStream.Initialize (System.IO.Stream stream) [0x00000] in <filename unknown>:0
at System.Xml.XmlInputStream..ctor (System.IO.Stream stream) [0x00000] in <filename unknown>:0
at System.Xml.XmlStreamReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0
at System.Xml.XmlTextReader..ctor (System.IO.Stream input) [0x00000] in <filename unknown>:0
at Amazon.S3.AmazonS3Client.transform (System.String responseBody, System.String actionName, System.Type t) [0x00000] in <filename unknown>:0
at Amazon.S3.AmazonS3Client.processRequestError (System.String actionName, System.Net.HttpWebRequest request, System.Net.WebException we, System.Net.HttpWebResponse errorResponse, System.String requestAddr, System.Net.WebHeaderCollection& respHdrs, System.Type t, System.Exception& cause) [0x00000] in <filename unknown>:0
at Amazon.S3.AmazonS3Client.handleHttpWebErrorResponse (Amazon.S3.Model.S3Request userRequest, System.Net.WebException we, System.Net.HttpWebRequest request, System.Net.HttpWebResponse httpResponse, System.Exception& cause, System.Net.HttpStatusCode& statusCode) [0x00000] in <filename unknown>:0
at Amazon.S3.AmazonS3Client.getResponseCallback[PutObjectResponse] (IAsyncResult result) [0x00000] in <filename unknown>:0
--
UploadUsingHighLevelAPI; Message = Error: SendFailure (Error writing headers);
StackTrace = at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in <filename unknown>:0
at Amazon.S3.AmazonS3Client.getRequestStreamCallback[PutObjectResponse] (IAsyncResult result) [0x00000] in <filename unknown>:0

dotconnect for postgres - Unknown parameter direction

I have problem with PgSqlCommandBuilder.DeriveParameters function. Sometimes it throws an exception “Unknown parameter direction.” without any visible reason. Problem occurs quite rarely. When I get a first exception, it throws always for all subsequent calls until. After restart of my app, it works properly. I have version 6.8.322. Have, anyone similar problem ? I try fight with it for some time but without success.
full stack trace
System.Exception: Unknown parameter direction.
at Devart.Data.PostgreSql.l.a (System.Data.Common.DbConnection A_0, System.String[] A_1) [0x00000] in <filename unknown>:0
at Devart.Data.PostgreSql.l.a (System.Data.Common.DbConnection A_0, Devart.Common.DbConnectionInternal A_1, System.String A_2, System.String[] A_3) [0x00000] in <filename unknown>:0
at Devart.Common.DbConnectionInternal.a (Devart.Common.DbConnectionBase A_0, System.String A_1, System.String[] A_2) [0x00000] in <filename unknown>:0
at Devart.Common.DbConnectionBase.GetSchema (System.String collectionName, System.String[] restrictionValues) [0x00000] in <filename unknown>:0
at Devart.Data.PostgreSql.PgSqlCommand.DescribeProcedure (System.String name) [0x00000] in <filename unknown>:0
at Devart.Common.DbCommandBase.CreateParameters () [0x00000] in <filename unknown>:0
at Devart.Data.PostgreSql.PgSqlCommand.c () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) Devart.Data.PostgreSql.PgSqlCommand:c ()
at Devart.Data.PostgreSql.PgSqlCommandBuilder.DeriveParameters (Devart.Data.PostgreSql.PgSqlCommand command) [0x00000] in <filename unknown>:0
at #Zs.#Ys.#Us (Devart.Data.PostgreSql.PgSqlCommand #Vs, System.Object[] #Ws) [0x00000] in <filename unknown>:0
at #Zs.#Ys.#Xs (System.String #Ms, #Ns #Ns, System.Object[] #Ac) [0x00000] in <filename unknown>:0 at Devart.Data.PostgreSql.l.a (System.Data.Common.DbConnection A_0, System.String[] A_1) [0x00000] in <filename unknown>:0
at Devart.Data.PostgreSql.l.a (System.Data.Common.DbConnection A_0, Devart.Common.DbConnectionInternal A_1, System.String A_2, System.String[] A_3) [0x00000] in <filename unknown>:0
at Devart.Common.DbConnectionInternal.a (Devart.Common.DbConnectionBase A_0, System.String A_1, System.String[] A_2) [0x00000] in <filename unknown>:0
at Devart.Common.DbConnectionBase.GetSchema (System.String collectionName, System.String[] restrictionValues) [0x00000] in <filename unknown>:0
at Devart.Data.PostgreSql.PgSqlCommand.DescribeProcedure (System.String name) [0x00000] in <filename unknown>:0
at Devart.Common.DbCommandBase.CreateParameters () [0x00000] in <filename unknown>:0
at Devart.Data.PostgreSql.PgSqlCommand.c () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) Devart.Data.PostgreSql.PgSqlCommand:c ()
at Devart.Data.PostgreSql.PgSqlCommandBuilder.DeriveParameters (Devart.Data.PostgreSql.PgSqlCommand command) [0x00000] in <filename unknown>:0
at #Zs.#Ys.#Us (Devart.Data.PostgreSql.PgSqlCommand #Vs, System.Object[] #Ws) [0x00000] in <filename unknown>:0
at #Zs.#Ys.#Xs (System.String #Ms, #Ns #Ns, System.Object[] #Ac) [0x00000] in <filename unknown>:0
SQL
SELECT pr.proname as name,
TYPNS.nspname AS Schema,
TYP.typname as ReturnType,
proargtypes as InParams,
pr.oid as FunctionOID,
proallargtypes as OutParams,
proargmodes as ArgumentModes,
proargnames as ArgumentNames
FROM pg_proc pr
JOIN pg_namespace TYPNS ON TYPNS.oid = pr.pronamespace
LEFT OUTER JOIN pg_type TYP ON TYP.oid = prorettype
WHERE proisagg = FALSE
AND TYPNS.nspname like E'%'
AND pr.proname like E'gethostslimit'
AND pg_get_userbyid(proowner)::varchar like E'%'
AND TYP.typname like E'%'
AND pr.oid = E'28444'
ORDER BY proname, FunctionOID;
RETURN
"name";"schema";"returntype";"inparams";"functionoid";"outparams";"argumentmodes";"argumentnames"
"gethostslimit";"public";"record";"2950";28444;"{2950,23,23}";"{i,o,o}";"{sessionuidparam,exitcode,hostslimit}"
This topic is discussed on Devart forums http://forums.devart.com/viewtopic.php?t=30006

key dumplication when adding: httpmodules

I am getting this error (it appears) when mod_mono auto restarts.Really need your help.
System.ArgumentException: Key duplication when adding: httpModules
at System.Collections.Hashtable.PutImpl (System.Object key, System.Object value, Boolean overwrite) [0x00000] in <filename unknown>:0
at System.Collections.Hashtable.Add (System.Object key, System.Object value) [0x00000] in <filename unknown>:0
at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd (System.String name, System.Object value) [0x00000] in <filename unknown>:0
at System.Collections.Specialized.NameObjectCollectionBase.BaseSet (System.String name, System.Object value) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection (System.String sectionName) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.InitOnce (Boolean full_init) [0x00000] in <filename unknown>:0
I add as the first item below the entry in my web.config, and it's still happening.
Please help me.

Issues with installing Orchard & Mono

I am currently running an Ubuntu Server 12.10.
I tried to install Orchard along with mono. When i try to start mono :
MONO_IOMAP=all xsp4
I get the following errors in the CLI:
Handling exception type ConfigurationErrorsException
Message is No factory for host (/home/shto/sites/test/Orchard/Web.config line 13)
IsTerminating is set to True
System.Configuration.ConfigurationErrorsException: No factory for host (/home/shto/sites/test/Orchard/Web.config line 13)
Server stack trace:
at System.Configuration.ConfigInfo.ThrowException (System.String text, System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadRemoveSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadConfig (System.Configuration.Configuration cfg, System.String streamName, System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.SectionGroupInfo.ReadConfig (System.Configuration.Configuration cfg, System.String streamName, System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.ReadConfigFile (System.Xml.XmlReader reader, System.String fileName) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Load () [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.Init (IConfigSystem system, System.String configPath, System.Configuration.Configuration parent) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password, Boolean fweb) [0x00000] in <filename unknown>:0
Exception rethrown at [0]:
at (wrapper xdomain-invoke) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
at System.Web.Hosting.ApplicationHost.CreateApplicationHost (System.Type hostType, System.String virtualDir, System.String physicalDir) [0x00000] in <filename unknown>:0
at Mono.WebServer.VPathToHost.CreateHost (Mono.WebServer.ApplicationServer server, Mono.WebServer.WebSource webSource) [0x00000] in <filename unknown>:0
at Mono.WebServer.XSP.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in <filename unknown>:0
at Mono.WebServer.XSP.Server.Main (System.String[] args) [0x00000] in <filename unknown>:0
When i installed mono i used the command: apt-get install mono-complete
Orchard currently does not run in Mono.

Embedded mono + app.config

I have embedded mono in a c++ program and loaded a dll which requires an app.config. I am getting this kind of error, does someone have an idea on how to ship *.config with an embedded mono ?
The stack trace :
System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.ArgumentException: The 'ExeConfigFilename' argument cannot be null.
at System.Configuration.ExeConfigurationHost.CheckFileMap (ConfigurationUserLevel level, System.Configuration.ExeConfigurationFileMap map) [0x00000] in <filename unknown>:0
at System.Configuration.ExeConfigurationHost.InitForConfiguration (System.String& locationSubPath, System.String& configPath, System.String& locationConfigPath, IInternalConfigRoot root, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.C[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0 onfiguration.InternalConfigurationSystem.InitForConfiguration (System.String& locationConfigPath, System.String& parentConfigPath, System.String& parentLocationConfigPath) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object
Self answer : you can't (as of 2013-04-30). To enable this behaviour, I had to change mono's framework sources mono/mcs/class/corlib/system/appdomain.cs :
public AppDomainSetup SetupInformation {
get {
return SetupInformationNoCopy; // newline
// AppDomainSetup setup = getSetup (); //old
// return new AppDomainSetup (setup); //old
}
}