XNA Shadow mapping - invalid model? - xna

I try to use shadow mapping sample from http://xbox.create.msdn.com/en-US/education/catalog/sample/shadow_mapping_1.
When I try to load my model there is an exception in:
effect.CurrentTechnique = effect.Techniques[techniqueName];
in DrawModel method.
An unhandled exception of type 'System.ArgumentNullException' occurred in Microsoft.Xna.Framework.Graphics.dll
Additional information: This method does not accept null for this parameter.
What can be wrong with my model?

Check that your techniqueName variable isn't null.
I'm betting effect.Techniques[null] throws a System.ArgumentNullException for the same reason Dictionary.Item does.

Related

Getting 'type X is not a subtype of type Y in type cast' without call stack

I see error in console without call stack:
flutter: [ERROR]: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, Object>' in type cast
Is there a way to enable call stack for such type of errors, so that I can find the root cause?
For this exact error it helps to search for as Map<String, Object> in the code and replace the cast with .cast<String, Object>() as
the article suggests.
But, yes, it would be helpful if the call stack could be enabled.

'List<dynamic>' is not a subtype of type 'List<Comment>'. Why can't Dart infer this type? How do I fix this?

I have nested comments. In order to fetch them from JSON, I have the following fromJson() function:
Comment.fromJson(Map<String, dynamic> json)
: id = json['id'],
...
children = json['children'] != null
? json['children'].map((c) => Comment.fromJson(c)).toList()
: null,
...
This checks if the current comment has any children comments, and if so, recursively parses them from JSON into a Comment. However when I run this, I get the following error:
[ERROR:flutter/shell/common/shell.cc(214)]
Dart Unhandled Exception:
type 'List<dynamic>' is not a subtype of type 'List<Comment>'
stack trace: #0 new Comment.fromJson (package:app/models/comment.dart:43:18)
Which points to the line where I assign children with children = json.... I'm new to dart, but I don't understand how mapping over a list, and returning a Comment doesn't let Dart infer the type of the list. How do I fix this? Adding as List<Comment> after toList() didn't work. If I add as Comment after Comment.fromJson(c), I get unnecessary cast.
Dart can't infer anything from json['children'].map(...).toList() because json['children'] is of type dynamic, and therefore it doesn't know what the .map call is going to resolve to at runtime.
At runtime, since .map is called without an explicit type, it ends up being a call to .map<dynamic>(...), and then .toList() returns List<dynamic>.
Try either:
Explicitly using .map<Comment>(...).
Casting json['children']: (json['children'] as List<Map<String, dynamic>>).map(...). It'd probably be a good idea to validate this anyway.

How can I inject IPrincipal using TinyIoC?

This line:
container.Register<IPrincipal>().UsingConstructor(() => HttpContext.Current.User);
throws the following exception:
Cannot register type System.Security.Principal.IPrincipal - abstract
classes or interfaces are not valid implementation types for
SingletonFactory.
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:
Tss.Rhnncp.DietPlanner.Bootstap.TinyIoCRegistrationTypeException:
Cannot register type System.Security.Principal.IPrincipal - abstract
classes or interfaces are not valid implementation types for
SingletonFactory.
Source Error:
Line 2663: throw new TinyIoCRegistrationTypeException(registerImplementation, "SingletonFactory");
Line 2664:
Line 2665: if (!IsValidAssignment(registerType, registerImplementation))
Line 2666: throw new TinyIoCRegistrationTypeException(registerImplementation, "SingletonFactory");
Line 2667:
I'm not familiar with TinyIoc, but I expect you need something like this:
container.Register<IPrincipal>(() => HttpContext.Current.User);

F# exception and inner exception property

in F# i can declare a custom exception like so:
exception Foo of string,
which will map the string to the Message property.
how do I declare one that I can later use to raise a caught exception as the inner exception of this one? In other words, how do i do something like (pseudo)
try
...
with e -> raise Foo (message, innerException) where innerException is e?
Thanks!
The simple declaration of exceptions using exception is limited in many ways. If you want to use other features of standard .NET exceptions (i.e. inner exception), then you can declare exception as a class:
open System
type FooException(message:string, innerException:Exception) =
inherit Exception(message, innerException)
You can also provide overloaded constructors, for example if you want to use null as a default value for InnerException.
The exception can be raised as an ordinary .NET exception using raise:
raise (new FooException(message, e))

Object reference not set to an instance of an object.(asp.net mvc)

Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 733: } Line 734: Line 735: private static bool
mAppDebug =
WebConfigurationManager.AppSettings["AppDebug"].ToLower().Contains("true");
Line 736: public static bool AppDebug Line 737: {
Source File: T:\MyProject\IMI03\Helper\IMISecurity.cs Line: 735
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.] IMI03.Helper.IMIApplication..cctor() in
T:\MyProject\IMI03\Helper\IMISecurity.cs:735
[TypeInitializationException: The type initializer for
'IMI03.Helper.IMIApplication' threw an exception.]
IMI03.Helper.IMIApplication.set_PasswordDay(Int32 value) in
T:\MyProject\IMI03\Helper\IMISecurity.cs:683
IMI03.MvcApplication.Application_Start() in
T:\MyProject\IMI03\Global.asax.cs:52
Couldn't find the erro... what kind of error and how to recitfy it...please??
The "AppDebug" setting likely doesn't exist, so calling ToLower() on it is throwing a NullReferenceException. Make sure you've spelled everything correctly and that the setting is actually there.

Resources