Dailycode.info

Short solution for short problems

AngularJS: Set ng-style text decoration

I was trying to set the text decoration from the controller to underlined or none, depending on some scope variable.

<row ng-style="{text-decoration: player1.turn}"><h2>{{player1.text}}</h2></row>

But first I got some errors: Error: [$parse:syntax] Syntax Error: Token '-' is unexpected, expecting [:] at column 6 of the expression [{text-decoration:

 Now I found why:

<row ng-style="{'text-decoration': player1.turn}"><h2>{{player1.text}}</h2></row>

I needed to put text-decoration between quotes. player.turn can hold none, underlined or any other decoration.


.Net WebAPI: A potentially dangerous Request.Path value was detected from the client (:).

Ever got this error?

A potentially dangerous Request.Path value was detected from the client (:).

I was trying to give a datetime in the url as parameter to a REST service. but when I used data time, the following error occurred.

http://localhost/Users/GetPlanForDate/2015-1-5%2008:00

First I changed the route, making the date a querystring.

http://localhost/Users/GetPlanForDate?date=2015-1-5%2008:00

This worked fine, but then I would have to change to many routes. So finally the solution came up.

I could just remove the ':' as potentially dangerous sign. The can be done in the web.config of your project:

Change this line:

<httpRuntime targetFramework="4.5" />

into this:

<httpRuntime targetFramework="4.5" requestPathInvalidCharacters="&lt;,&gt;,*,%,&amp;,\,?" />

Now the time using the ':' will be passed to your web api.

Some functions have the datetime as first parameter, but have more following, like this:

http://localhost/Users/GetPlanForDate/2015-1-5%2008:00/1

So in this case it's nice that you can use the Route parameters for datetime.

[Route("Users/GetPlanForDate/{date}/{shift}")]

public GalvaSFIMobileDataLayer.GP_MES_ShiftPlans GetPlanForDate(DateTime date, int shift)

{

            //GetMESHeaders(OperationContext.Current);

            return PL.GetPlanForDate(date, shift);

}


VS 2010/2012 crashes when opening designer.

This can be a really time eating problem. In my case this problem came suddenly, in a class that didn't change for a long time. 

The error looked something like this:

Faulting application name: devenv.exe, version: 10.0.40219.1, time stamp: 0x4d5f2a73

Faulting module name: KERNELBASE.dll, version: 6.1.7601.18409, time stamp: 0x53159a86

Exception code: 0xe0434352

Fault offset: 0x0000c42d

Faulting process id: 0x1898

Faulting application start time: 0x01d00d526a76a093

Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe

Faulting module path: C:\Windows\syswow64\KERNELBASE.dll

Report Id: f6f5bf23-7945-11e4-afad-02004e435049

When you experience this kind of behavior, it could be that an add-in is causing the problem or some update of software. In our case this didn't help.

So at the end we found that is was a problem in the page load of a form, it gets executed when you open the designer. We had some code that went to the database. The strange this is that this worked for years and now suddenly it starts crashing on all development PC's. The solution to this problem is to prevent the code from being run at design time by using the System.ComponentModel.LicenseManager.UsageMode:

Private Sub BaseForm_Load(ByVal sender As Object, ByVal e As System.EventArgs)

Handles Me.Load

    Try

       If System.ComponentModel.LicenseManager.UsageMode = System.ComponentModel.LicenseUsageMode.Runtime Then

          HandleFormDisableButtons()

          Translate()

       End If

    Catch ex As Exception

ExceptionHandling.ShowException(ex)

    End Try

 

End Sub


SAP: Program (IS_VARIANT-REPORT) not specified (SAP Message 0K522)

I looked on the internet for a while, but couldn't find a solution that worked for me.
I noticed that when I used the transaction, this error came, but when I ran the program from SE383 it didn't gave any error.

So I looked myself for a short while and found out that it was the transaction I created that had a problem. I recreated the transaction using SE80. First I deleted the old transaction. Then I created the transaction following these steps:

1. Create the tranaction:

2. Select the second option from the list:

3. Then fill in the program behind the transaction and save.



I believe the mistake I did was the first time I created the transaction, I selected the first option in step 2.

iOS : duplicate interface definition for class

I had a problem. It was a small search effort, but I could solve it without creating a new project etc...

The thing was I had a Class B that was importing Class A.

Then I had a class that imported Class B and also Class A.

When I did this, these problems occured. 

Eg. A SOAP webservice Class imports all the Entities that are passed over the web.

 

Class goToSchoolWebservice.

#import "person.h"

#import "school.h"

...

 

Then I had a Singleton class used for caching that had the Logged in Person and also a ref to the webservice class.

Class variableStore

#import "person.h"

#import "goToSchoolWebservice.h"

 

--> this is where is went wrong!!

So watch out for these circular references. ITs not so easy to detect them!


implicit declaration of function is invalid in c99

As a c# developer, I'm sinning against a lot of syntax in objective C.

For one is the explicit calls to functions. I keep forgetting the square braces and hence getting the error:

implicit declaration of function is invalid in c99

Eg : FillValues(); should be [self FillValues];

- (void) FillValues

{

...

}


The EntitySet name ‘ ' could not be found.

Frustrating error, easy to fix, hard to find!

Server Error in '/' Application.


The EntitySet name 'Entities.GP_MES_Complaint' could not be found. 

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.InvalidOperationException: The EntitySet name 'Entities.GP_MES_Complaint' could not be found.

Source Error: 

 

Line 104:        public ObjectSet<GP_MES_Complaint> GP_MES_Complaint

Line 105:        {

Line 106:            get { return _gP_MES_Complaint  ?? (_gP_MES_Complaint = CreateObjectSet<GP_MES_Complaint>("GP_MES_Complaint")); }

Line 107:        }

Line 108:        private ObjectSet<GP_MES_Complaint> _gP_MES_Complaint;


In my case I made a mistake in the entity connection string. Because I’m working with multiple edmx models on the same database, I just copied the connection string. But then the entity framework has troubles since it adds mapping stuff to the default connection string:

   <add key="GMConnectionString" value="metadata=res://*/GMModel.csdl|res://*/GMModel.ssdl|res://*/GMModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source…

    <add key="GMSysConnectionString" value="metadata=res://*/SYS.GMSystemModel.csdl|res://*/SYS.GMSystemModel.ssdl|res://*/SYS.GMSystemModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source…

 

 My mistake was I used the connection string of an existing edmx model, but I had to change it to map the edmx model. Haaa. Frustrating!

 

 <add key="GMViewsConnectionString" value="metadata=res://*/VIEWS.GMViewsModel.csdl|res://*/VIEWS.GMViewsModel.ssdl|res://*/VIEWS.GMViewsModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source…


Entity Framework and There is already an open DataReader associated with this Command which must be closed first.

There is already an open DataReader associated with this Command which must be closed first.

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.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.

Source Error: 

When using the entity Framework I got that error. Got it when I was looping within a loop. Since there was no association between the objects, I had to do a loop en inner loop, it looks like this:

foreach (GP_PROJ_ProjectSteps step in Ents.GP_PROJ_ProjectSteps.Where(s=>s.ProjectID == project.ProjectID))

{

    foreach (GP_PROJ_ProjectTasks task in Ents.GP_PROJ_ProjectTasks.Where(d => d.StepID == step.StepID))

    {

        Ents.GP_PROJ_ProjectTasks.DeleteObject(task);

    }

    Ents.GP_PROJ_ProjectSteps.DeleteObject(step);

}

Ents.GP_PROJ_Projects.DeleteObject(project);

Ents.SaveChanges();

 

The solution to this problem was to allow or enable Multiple Active Result Sets (MARS). This is done in your connection string:

Data Source=DBServer;Initial Catalog=MyDB;Persist Security Info=True;User ID=DBUSER; Password=PWD;MultipleActiveResultSets=true;


Unable to update the EntitySet '' because ...

Got this error using the entity framework and self-tranking entities:

Unable to update the EntitySet 'MyEntity' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.

Couldn't find the problem at first, even google didn't really gave me any thoughts. Untill I noticed that I forgot to set a primary key in the database table. Problem solved. Or so I thought.

Apparently Visual studio created a key itself on the edmx model, off course the wrong one. After a update from database, the model added the correct key, but didn't removed the key which it had created itself. So I removed it myself, then did an updated the model again from the database.