New Posts New Posts RSS Feed: using weirdness
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

using weirdness

 Post Reply Post Reply
Author
slkiwi View Drop Down
Newbie
Newbie


Joined: 19-Jul-2010
Posts: 1
Post Options Post Options   Quote slkiwi Quote  Post ReplyReply Direct Link To This Post Topic: using weirdness
    Posted: 19-Jul-2010 at 3:52am
Hi
 
I'm helping a team of newbie devs evaluate DevForce and have run into some very weird stuff!
 
The main problem I have is that the using statements in the ViewModel class need to be exactly right.
 
I have the following code:
 
using System.Collections.ObjectModel;
using IdeaBlade.EntityModel;
 
namespace XXX.DevForce.SL
{
    public class MainPageViewModel
    {
        private ObservableCollection<Customer> Customers { get; set; }
        private void Loaded()
        {
            Customers = new ObservableCollection<Customer>();
            var mgr = new DevForceDbEntities();
            var query = mgr.Customers;
            query.ExecuteAsync(op => op.Results.ForEach(Customers.Add));
        }
    }
}
 
 
Now the above doesn't compile - I get an ambiguous reference on op.Results.
 
 
The above code was typed without the using statements, then (using ReSharper) the using statements were inserted. (That is, I inserted the using statements that ReSharper suggested. This normally works fine.)
 
But something is wrong - I have to manually correct the using statements to read as follows:
 
using System.Collections.ObjectModel;
using IdeaBlade.Core;
using IdeaBlade.EntityModel;
 
 
Given that we're ReSharper fans, this is of concern to us.
 
So, what is causing this? I really don't understand - but it's a big problem for us. It's taken me quite some time chasing down this problem to identify the exact cause.
 
 
 
On another matter (and I don't know whether it's related to DevForce or not) I have tried to implement an IValueConverter class in my Silverlight project. However, when I refrence it in the XAML (in the UserControl.Resources) I get errors in the Cider designer:
 
Error 1 The type 'SL:BoolToVisibilityConverter' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. C:\Projects\Visual Studio Projects\XXXDevForce1\XXX.DevForce.SL\MainPage.xaml 6 10 XXX.DevForce.SL
 
 
I have tried the exact same code in another non-DevForce Silverlight 4 project and the IValueConverter class works fine.
 
I have found that if I put the IValueConverter into a separate Silverlight class library and reference it from the main Silverlight project I can get around the error.
 
 
 
Anyway, any help with these issues would be much appreciated.
 
Best regards,
 
Craig
 
(Auckland, New Zealand)
 
 
 
 
 
 
 
 
 
 
Back to Top
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Posted: 19-Jul-2010 at 2:08pm

Re: R# - Have encountered this too. I am a R# fan. Not sure what to do. Tempted to blame R# :-)

I believe the root cause is the ordering of the usings which plays into the compiler's resolution of competing extension methods. That's why one ordering of the "usings" works and the other does not. I'm not sure that there is anything we COULD do about it.
 
Personally, I think of it as a PITA, not a "big problem". You encounter it once per ViewModel class. If you're writing that many ViewModel classes by hand, I'd be tempted to (a) write a CodeSnippet, (b) write a R# live template or (c - my fav) write a Visual Studio VM class file template to spit out the boiler plate.
 
--
 
Re: Designer Troubles
 
"Our Bad".
 
Through DevForce v.6.0.3 we required that the paired model assemblies (regular .NET and Silverlight .NET) have the same assembly name. Our bad. The application compiles and works with this convention but tooling hates it.
 
The Designers (and R# and TFS btw) get confused when they see two assemblies with the same name. Only one of them is used in Silverlight.
 
Unfortunately, the tooling lives in regular .NET and decides to look at both assemblies EVEN THOUGH ONLY THE SL ASSEMBLY COULD EVER BE USED.
 
Fat chance getting Microsoft (or R#) to fix this. We must accommodate them.
 
As of DF v.6.0.4 (to be released shortly), the desktop and SL model assemblies can AND SHOULD have distinct assembly names (e.g., Model.Desktop and Model.SL). 
 
Our templates will take care of this for new applications. You will have to change the assembly names of model projects in existing applications (like yours). Your Designer problems will go away.
 
N.B.:
 
The namespaces must be the same. The employee class must be "YourModel.Employee" in both "YourModel.Desktop" and "YourModel.SL"
 
--
 
When converting simple demo applications with two projects (SL and Web), the Web project is the regular .NET model project. For example, in apps created with templates from v.6.0.3, the assembly names in MyApp and MyApp.Web are both "MyApp". I recommend that you leave that assembly name alone in the web project. Go to the Silverlight application project and change it's name to "MyApp.SL".
 
--
 
Sometimes, when you change the name of the regular .NET assembly with the EDMX in it, the app won't start; you'll see an exception complaining about not being able to find the endpoint and asking you to try all kinds of stuff (e.g, set Copy Local = true for the IdeaBlade assemblies). These are all common causes of the problem DevForce is struggling to resolve. They are NOT the cause in this case.
 
The problem is that both Visual Studio and EntityFramework EDMX got confused. It's holding on to an old EF connection string that describes the location of the Entity Framework part files (CSDL, MSL, and SSDL).
 
The telltale sign of this: open the EDMX and "Update from Database". If it needs help finding the database (it will show a wizard for finding the database), you know that the EF connection string has changed.
 
Often you can't find the difference. It's there but the string is so long that it's hard to see.
 
- Help it find the database.
- Find its updated <ConnectionString> either in the model app.config or the web.config.
- Copy that <connection string> to the config file(s) that need it (e.g., web project's web.config, test project app.configs, etc.).
- If your config defines EDM keys, update them with the string
 
** Extra Voodoo **
 
Sometimes you STILL get trouble. Maddening. Here are some steps that I follow (after hitting my head on the desk):
 
- Clean the solution
- Delete bin directories
- Close and reopen Visual Studio
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down