custom device adapter

S

steph

I am unable to get my site to work with a new device
adapter set that I have created. If you call a page on the
site you get the error message:

Server Error in '/' Application.
-----------------------------------------------------------
---------------------

Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request.
Please review the specific error details below and modify
your configuration file appropriately.

Parser Error Message:
Type 'BangoAdapters.BangoMLPageAdapter' used as
PredicateClass not found.

Source Error:


Line 822: <control
Line 823:
name="System.Web.UI.MobileControls.Label"
Line 824:
adapter="System.Web.UI.MobileControls.Adapters.HtmlLabelAda
pter" />
Line 825: <control
Line 826:
name="System.Web.UI.MobileControls.LiteralText"


Source File: c:\winnt\microsoft.net\framework\v1.1.4322
\Config\machine.config Line: 824


-----------------------------------------------------------
---------------------
Version Information: Microsoft .NET Framework
Version:1.1.4322.573; ASP.NET Version:1.1.4322.573




I created the new device adapter set based upon the
existing wml one. The code for this is in the
machine.config:

.. all the other existing device
adapters ...

<device
name="BangoMLDeviceAdapters"
inheritsFrom="WmlDeviceAdapters"

predicateClass="BangoAdapters.BangoMLPageAdapter"
predicateMethod="DeviceQualifies"

pageAdapter="BangoAdapters.BangoMLPageAdapter">
</device>

</mobileControls>



Then I have created the predicate class which has just the
predicate method, which determines whether or not this
device adapter should be used, based on some sample code
in an MSPress book. The only difference between this and
the sample code in the book is I had to put 'new' at the
start of the DeviceQualifies property else it would not
build as it said "The keyword new is required
on 'BangoAdapters.BangoMLPageAdapter.DeviceQualifies
(System.Web.HttpContext)' because it hides inherited
member 'System.Web.UI.MobileControls.Adapters.WmlPageAdapte
r.DeviceQualifies(System.Web.HttpContext)'". Alternatively
I also tried calling it DeviceQualifies2 and changed the
predicateMethod in the code above to this method too, but
that didn't work either:


using System;
using System.Web;
using System.Web.Mobile;
using System.Web.UI.MobileControls.Adapters;


namespace BangoAdapters
{
public class BangoMLPageAdapter : WmlPageAdapter
{
new public static bool DeviceQualifies
(HttpContext context)
{
MobileCapabilities capabilities =
((MobileCapabilities)context.Request.Browser);
bool qualifies =
capabilities.Browser == "Test Browser";
return qualifies;
}
}
}



This should just inherit from the WmlPageAdapter and
because at the moment I haven't over-ridden any of the
properties or methods produce exactly the same output as
the WmlPageAdapter.


The error message seems to be saying it can't find the
predicate class. The suggestion in the book seems to be
that if the assembly containing the predicate class is
referenced in the project then all should be well. However
this seems not to be the case. I'm sure that the assembly
is valid since the intellisense and the drill down in
Visual Studio can both correctly see the class in the
assembly so I'm guessing that the machine.config does not
know about the assembly for some reason.

I tried adding an assembly tag in the machine.config
specifying the name and version of the assembly as follows
but this did not seem to cure the problem. Then I tried
adding the assembly to the Global Assembly Cache to see if
that allowed machine.config to find it but that did not
seem to make any difference either.

<assemblies>
<add
assembly="BangoAdapters,Version=1.0.1396.34694,Culture=neut
ral,PublicKeyToken=efd73c7058cf2996" />
</assemblies>

Can anyone see what the problem is here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top