[mapserver-users] Re: Mapscript c# VS 2010 framework 4 and memory leaks

James Perrins james.perrins at gmail.com
Thu Apr 22 07:20:43 EDT 2010


OK - been looking into this a bit.

With luck it may just be a case of having to mark the assemblies) -
each class with:
[assembly: SecurityRules(SecurityRuleSet.Level1)]

Need to add:

using System.Security;
[assembly: SecurityRules(SecurityRuleSet.Level1)]

I haven't yet found anything that says where you can do this once for
an assembly - or whether you have to mark each class (probably doesn't
hurt to mark each class) - all the examples are a bit trivial

I've found some source in a slightly different location from your suggestions:
~\mapserver-5-6\mapscript\csharp

But as you say - when I tried adding in the above change - and ran the
makefile - the swig (which I'm not familiar with) replaced my changes
- so I haven't yet been able to test if it really works.
Is there an easy edit to the makefile to disable the swig regeneration ?

As an aside (and why I've been caught with this) is that referencing
the mapscript_csharp.dll in a CLR 4 app works in design mode
apparently fine.  Its only when you try and run the compiled exe (or
as it turns out switch off "suppress jit optimization on module load
(managed code only)").  At that point even trying to load a mapObj
results in numerous memory errrors

Thanks
James


On Thu, Apr 22, 2010 at 11:56 AM, Tamas Szekeres <szekerest at gmail.com> wrote:
> The geneated sources should be in /swig/csharp/ogr, /swig/csharp/gdal,
> /swig/csharp/osr
> However in the final version of the patch, the corresponding interface
> files should be updated instead (in /swig/include/csharp), because the
> source files are regenared during the build process.
>
> If you find out the desired changes in the generated sources (.cs) I
> could help in making the related changes in the SWIG interface files.
>
> Best regards,
>
> Tamas
>
>
>
> 2010/4/22 James Perrins <james.perrins at gmail.com>:
>> Thanks for that - I was looking for a setting like that but failed to find it.
>>
>> However I'm not sure its the complete solution (as I've tried it and
>> still seem to have the same error) - the link you give states that you
>> need to still add:
>> [assembly: SecurityRules(SecurityRuleSet.Level1)] to your assembly to
>> revert to CLR2 transparency.
>>
>> Unfortunately this
>> http://msdn.microsoft.com/en-us/library/dd409253(v=VS.100).aspx states
>> that even with the switch set - it doesn’t effect transparency rules -
>> which appears to be the breaking change :-(.  I'm assuming code
>> changes need to me made to mapscript_csharp rather than any of my code
>> consuming it.
>>
>> If I was going to have a go at adding this into the mapscript_csharp
>> wrapper could you give me a pointer to where to look for the source -
>> I seem to have compiled it OK - but am having trouble seeing where the
>> source is amongst everything else.
>>
>> Thanks again
>> James
>>
>>
>> On Thu, Apr 22, 2010 at 9:29 AM, Tamas Szekeres <szekerest at gmail.com> wrote:
>>> 2010/4/22 James Perrins <james.perrins at gmail.com>:
>>>>
>>>>
>>>> Things seemed to compile - but when I call something like
>>>> mapObj(MyMapFile) I get an error about
>>>>
>>>> "Attempt by security transparent method
>>>> 'OSGeo.MapServer.mapObj..ctor(System.String)' to call native code
>>>> through method 'OSGeo.MapServer.mapscriptPINVOKE.new_mapObj(System.String)'
>>>> failed.  Methods must be security critical or security safe-critical
>>>> to call native code."
>>>>
>>>
>>> This appears to be due to the different level of the security
>>> transparency setting of .NET FW 4.0 vs. the previous versions.
>>> I'll require some further testings to find out the desired solution,
>>> however you might want to try with the suggestions below:
>>> http://blogs.rev-net.com/ddewinter/2009/05/20/opting-out-of-security-changes-in-net-4/
>>>
>>> Best regards,
>>>
>>> Tamas
>>>
>>
>


More information about the mapserver-users mailing list