We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Concurrently converting several DXF files

When performing several conversions from DXF to jpeg (all in their own thread) I’m getting exceptions like these:

Individually they all convert fine.

Exception: KeyNotFoundException

Message: The given key ‘Aspose.CAD.FileFormats.Cad.CadTables.CadVportTableObject’ was not present in the dictionary.

Stack Trace:
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Aspose.CAD.FileFormats.Cad.CadObjects.CadBase.#=zY3iDRjk1p$2J()
at Aspose.CAD.FileFormats.Cad.CadObjects.CadBase.#=zo00ou3w=(String #=z7BdCCgA6OM0u, CadEntityAttribute #=zds3uYIo=, CadCodeValue #=zEb_mALE=)
at #=zin7f7sv5$vufzWMpRNWbpd48iWY_w0LdGQnm6_EoAAypEMJDm5fcOo8=.#=zF1difJ0=(CadBase #=zqrGNnGg=, CadEntityAttribute #=zds3uYIo=)
at #=z3CYZMlsqd0qWtBJEIDGWh$9x0n7YdiWlABIBNJCcVKWsGJTjWQ==.#=zWEpzZ_BlsiVo(CadBase #=zqrGNnGg=)
at #=z3CYZMlsqd0qWtBJEIDGWh$9x0n7YdiWlABIBNJCcVKWsGJTjWQ==.#=zirl8Ah3pI3N9f1PUcQ==(CadVportTableObject #=zqrGNnGg=)
at Aspose.CAD.FileFormats.Cad.CadTables.CadVportTableObject.#=z3KPgDbo=(#=z0J7S2wcDXpI2DhlCnfUk0Q86hWc3bOTg9jEg9CbVZsRQ #=zRWILLnY=)
at #=zVG4YdbRWrzcRH8fTSqLdnQTCatg2m_lfPugEhK4pYDtv_MYBTg==.#=zQJBYR0Y=(CadBase #=zqrGNnGg=, #=zZPKWl_0ucKQ$L91qsc5oUbHS9telVq6Wqs$8ELo= #=z0k5PavU=, String #=z7BdCCgA6OM0u, CadEntityAttribute #=zx9CJNZOl4kKu, Boolean #=z$PWpz3eN4jMLtHPDXA==)
at #=zVG4YdbRWrzcRH8fTSqLdnQTCatg2m_lfPugEhK4pYDtv_MYBTg==.#=zQJBYR0Y=(CadBase #=zqrGNnGg=, #=zZPKWl_0ucKQ$L91qsc5oUbHS9telVq6Wqs$8ELo= #=z0k5PavU=, Boolean #=z$PWpz3eN4jMLtHPDXA==)
at #=zKf28ONAoD3lWr6kjnB3AdQEy57SU$7jsBtGNBhs45yxc.#=zII_4k$shBgqGzKYi9w==(CadCodeValue #=zc$Kq9Jo=)
at #=zKf28ONAoD3lWr6kjnB3AdQEy57SU$7jsBtGNBhs45yxc.#=zzcSEqtzYuaHm()
at #=zKf28ONAoD3lWr6kjnB3AdQEy57SU$7jsBtGNBhs45yxc.#=zoi4q7Tc=()
at #=zRN29L9zWvuOTCv2KFbRx8fRKGtb4rb2sNP6Zjh4=.#=zh2aJCag=(StreamContainer #=zZA5P0j5HMoSW, LoadOptions #=zp1tqkxzzlfWQ)

or

Exception: InvalidOperationException

Message: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection’s state is no longer correct.

Stack Trace:
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.set_Item(TKey key, TValue value)
at #=z6A$d_74EZDa2m_gEmsRAzsq9mm0LGQoLGPWj5QMTcfULNXLp6PFv8mSPVCDAwo0gCA==.#=zzku1UkMPCYbT(#=zfpP18RGzQ60cSrycsf8ZsKs= #=z9k0339I=, Double #=zjBNCuvCOwxeQ)
at #=ztvs5tBnKP5NRWw$GE6FLb1VyC81ovRhK3KzNwWY9tP30SLJu82Bva2_oCR0OW0$YKg==.#=z5EpgjdxkAjSJ(#=zR2tLDOhRsSWonQ1tG3d5wFhMSh3n3BWim03bK_SYkqLECdIrghjpdurqh$J_ERK2Jg== #=zD5hIixg=, String #=z0wHX_24huwwQ)
at #=ztvs5tBnKP5NRWw$GE6FLb1VyC81ovRhK3KzNwWY9tP30SLJu82Bva2_oCR0OW0$YKg==.#=zGHfesgXM5s6B(#=zvt7hJC68MrvW3crJDd4REdtmH4EhRdtzWawqeHrl1jZNEgGBWhAEq4I= #=zkhbSMoCeQeus0aDJZEONUkk=, #=zB2K$fQGIZipQisqftRFrJg4x9_fAg13LvLCM2Tvt7NlMjFnfZlymo6t6Yv60 #=zScdvqZ3MzWqm, #=z3tffIQ_h6argn2LAMLO0pNGQDzFR_81AZ60Xkxj6_ZFfKH_EIqcG$7ZfXWfpA99E7w== #=zayS7uTc=, Boolean #=zZ6MY5HaH1sl5, TransformationMatrix #=zptDN3S00GeUpFRmm4g==, Boolean #=zCZW7ipo=)
at #=z0sBfBIL_uFfc$ef0DQO_nN1hk0KG3y0MxxU$iqYsUHdAEDY3uaN5IJN_JBxGSRPZKQ==.#=zO92QC2u5P1zU(CadBaseEntity #=zdFZ6Bzs=, #=zvt7hJC68MrvW3crJDd4REdtmH4EhRdtzWawqeHrl1jZNEgGBWhAEq4I= #=zkhbSMoCeQeus0aDJZEONUkk=, #=zB2K$fQGIZipQisqftRFrJg4x9_fAg13LvLCM2Tvt7NlMjFnfZlymo6t6Yv60 #=zScdvqZ3MzWqm, Cad3DPoint #=z9bPxdL39CQF5, Boolean #=zJFTIKUX0bO4BH2khAg==, List1& #=zDSOVt1A=, TransformationMatrix #=zngPO_KVUG5Y6) at #=z0sBfBIL_uFfc$ef0DQO_nN1hk0KG3y0MxxU$iqYsUHdAEDY3uaN5IJN_JBxGSRPZKQ==.#=zKDhTgmE=(CadBaseEntity #=zdFZ6Bzs=, #=zvt7hJC68MrvW3crJDd4REdtmH4EhRdtzWawqeHrl1jZNEgGBWhAEq4I= #=zkhbSMoCeQeus0aDJZEONUkk=, #=zB2K$fQGIZipQisqftRFrJg4x9_fAg13LvLCM2Tvt7NlMjFnfZlymo6t6Yv60 #=zScdvqZ3MzWqm, Cad3DPoint #=z9bPxdL39CQF5) at #=zGgEdSY5Rt8Xta$q4Lko7z8eAoBmVNyssMmjtsGquxTjGx1CAqsi3D3DMYPcSsUHf9EoAGIGSvRZD.#=zKDhTgmE=(CadBaseEntity #=zdFZ6Bzs=, #=zvt7hJC68MrvW3crJDd4REdtmH4EhRdtzWawqeHrl1jZNEgGBWhAEq4I= #=zkhbSMoCeQeus0aDJZEONUkk=, #=zB2K$fQGIZipQisqftRFrJg4x9_fAg13LvLCM2Tvt7NlMjFnfZlymo6t6Yv60 #=zScdvqZ3MzWqm) at #=zvt7hJC68MrvW3crJDd4REdtmH4EhRdtzWawqeHrl1jZNEgGBWhAEq4I=.#=z_JYvbQA=(CadBaseEntity[] #=zFCsu32g=, String #=zVkt4q0jc30kLWGNcEw==, CadBaseEntity #=zdFZ6Bzs=, Int32& #=zpxhSXzCi2ewZO37j0A==) at #=zvt7hJC68MrvW3crJDd4REdtmH4EhRdtzWawqeHrl1jZNEgGBWhAEq4I=.#=z6F8jqE_qJOWF5L$QULYOunQ=.MoveNext() at #=zh2IOFkpF9JuwKOe5xcWZSSXb0z9kmnlIO4MrGDc=.#=z92hJdEqkNvNlWhLAaQ==(#=zt3SHXGnUJUDn0Wl8TZ_Gf_XWj5Rd4osqZy7D1oOoGBdRD53IqA== #=zSz4gZX3cXXqn5jhNaQ==, ImageOptionsBase #=zNWld60A=, List1 #=zCRp0pnk=, Int32 #=zJ_xI9F3gX7ls, Boolean #=zaOSLRh4=, VectorRasterizationOptions #=zXj9$xP8tYvjp0fGYVPtknm8=, #=zmVEsjXtD4Wc6LJsOqA1l3kzgDthQ #=zEYXp9JQd0Wnw, Boolean& #=zB6MLD3hg6v4Y, #=zpNMeySvtDmMYffbO1YrZIPk=& #=zLKvvp7tAhjHd, Boolean& #=zGWLxvDh0jHs9)
at #=zh2IOFkpF9JuwKOe5xcWZSSXb0z9kmnlIO4MrGDc=.#=zGHfesgXM5s6B(Image #=zhyiKGsw=, #=zt3SHXGnUJUDn0Wl8TZ_Gf_XWj5Rd4osqZy7D1oOoGBdRD53IqA== #=zSz4gZX3cXXqn5jhNaQ==, Stream #=zVlin5p0=, ImageOptionsBase #=zNWld60A=, Rectangle #=zXtULc6mV8gRO)
at #=zSgGY1NxUOkq3LpQzAyrq7EIgHCnlHxBVByvBPKY9wWUm.#=zKDhTgmE=(Image #=zhyiKGsw=, Stream #=zVlin5p0=, ImageOptionsBase #=zNWld60A=, Rectangle #=zXtULc6mV8gRO)
at Aspose.CAD.Image.#=z2nQhRlE3ITNUPevNKyeUpxU=.#=zzyJecYVcdC3HluRcqA==(CancellationToken #=z1nhSlD0=)
at #=zVlORPsLXUOfjMqqZEj05Jog=.#=zTbP4oGhJIcOx(Action`1 #=zwKOLOxE=, Boolean #=z_mksRQ0bR_6J, Int32 #=zr7szI8KSp2EC, CancellationToken #=zciitcuE=)
at Aspose.CAD.Image.#=zsML$ZMTs00FQeWaENw==.MoveNext()

@nielsbosma,
Hello, we need the entire example for this case, could you please attach here the code and files you use.

This is an issue in 22.11.0 that is not present in 22.4.0.

using Aspose.CAD;
using Aspose.CAD.ImageOptions;

var tasks = Enumerable.Range(0, 100).Select(CreateTask);

await Task.WhenAll(tasks);

Task CreateTask(int i = 0)
{
    return Task.Run(() =>
    {
        try
        {
            var image = Image.Load(@"sample.dxf");
            var imageOptions = new JpegOptions();
            var options = new CadRasterizationOptions
            {
                PageHeight = 500,
                PageWidth = 1000
            };
            imageOptions.VectorRasterizationOptions = options;
            image.Save($"sample_{i}.jpeg", imageOptions);
        }
        catch (Exception exception)
        {
            Console.WriteLine(exception);
        }
    });
}

@nielsbosma,
is this true for any dxf on your side or just with some particular files?

I just took a random sample DXF.

sample.zip (61.6 KB)

@nielsbosma,
I have created CADNET-8911 to investigate this issue.