Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • PascalN 1 post 21 karma points
    Mar 27, 2010 @ 06:34
    PascalN
    0

    Error when getting umbracoFile property of a Media from IronPython

    Hello,

    I'm new to Umbraco so I hope that question is not trivial or has not been answered before.  Anyways I couldn't find anything else.

     

    From IronPython I'm trying to get the url of an image that is uploaded in the media library.

    If I do the following (inspired by http://our.umbraco.org/forum/developers/api-questions/7993-Get-URL-of-media-file?p=0 )

     

    file = Media(1062)
    url = file.getProperty("umbracoFile")
    print url

     

    I get the error at the bottom but if I do the following I get the url (inspired by http://forum.umbraco.org/yaf_postst4929_Getmedia-in-usercontrol.aspx )

     

    xn = umbraco.library.GetMedia(1062, False)
    xn.MoveNext()
    xn2 = xn.Current.Select("data[@alias='umbracoFile']")
    xn2.MoveNext()
    url = xn2.Current.Value
    print url

     

    Anyone have an idea?

    Thanks;

    Pascal

     

    This is using 4.0.3 on Win7x64 IIS 7.5 .Net 3.5

     

    Error

    Exception has been thrown by the target of an invocation.
    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at umbraco.scripting.python.executeFile(String file) at umbraco.macro.loadMacroPython(macro macro, Hashtable attributes, Hashtable pageElements)

    [A]System.Collections.Generic.List`1[umbraco.cms.businesslogic.propertytype.PropertyType] cannot be cast to [B]System.Collections.Generic.List`1[umbraco.cms.businesslogic.propertytype.PropertyType]. Type A originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll'. Type B originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:\Windows\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll'.
    at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem) at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem) at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemRemovedCallback refreshAction, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem) at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem) at umbraco.cms.businesslogic.ContentType.get_PropertyTypes() at umbraco.cms.businesslogic.ContentType.getPropertyType(String alias) at umbraco.cms.businesslogic.Content.getProperty(String alias) at getProperty##40(Object , Object ) at IronPython.Compiler.MethodBinder.TargetSet.Call(ICallerContext context, CallType callType, Object[] args) at C:\inetpub\umbraco_403\python\TestPython.py##17(ModuleScope ) at IronPython.Hosting.CompiledCode.Execute()

  • Jonas Eriksson 930 posts 1825 karma points
    Aug 30, 2010 @ 16:31
    Jonas Eriksson
    1

    Hi, late answer, but anyways: if you add references to cms and businesslogic you should get around your problem.

    clr.AddReference('cms')
    clr
    .AddReference('businesslogic')

    Kudos to Immo Wache, see http://our.umbraco.org/forum/developers/api-questions/4106-Umbraco-3-Create-node-with-Python

    Alternatively, run Umbraco v 4.5+

    Hth / Jonas

Please Sign in or register to post replies

Write your reply to:

Draft